TMS WebCore iterate through webdataset

I have a TMS WEB application retrieving data from TMS XData REST server.
I am using TXDATAWebConnection to connect to the REST server.
I am using TXDATAWebDataSet to connect to an entity...(Q08).
I then call Q08.LOAD to load data to dataset.
I have a TWebDBGrid with Q08 for datasource.dataset.
The data loads and shows correctly in the TWebDBGrid.


I wish to show the data in a TWebStringGrid by iterating through Q08 like I do in my Windows desktop applications and I can't get Q08 to contain any data. I do it like this:

  2. Q08.load;
  3. Q08.first;
  4. while not Q08.eof do
    TWebStringGrid.cells[column,row] := Q08.fieldbyname('DESCRIPTION').AsString;;

This is not my code but instead a snippet to hopefully show you what I am trying to do.
The problem is, when I use DATASET.OPEN, DATASET.LOAD, DATASET.FIRST, there isn't any data in Q8. BUT it works fine when loading it into a DBGRID using only DATASET.LOAD.

What is the correct sequence of steps to do when using a TXDATAWebDataset and I wish to iterate through the table one row at a time? Do I use DATASET.OPEN or only DATASET.LOAD?

Steve Wagner
Instamation Systems Inc.

Q08.Load is an asynchronous method. After you call it, the third statement, Q08.First is immediately executed, but the dataset is not loaded yet.

You have two options:

  1. Call Load and then put the rest of your code in the AfterOpen event. That's the event executed after the asynchronous Load operation is finished.

  2. Use TXDataWebClient to retrieve data from the server directly using more flexible methods (like List). TXDataWebClient also provides you with async-flagged methods, meaning you can call them using await. There is a demo in XData installation folder (\demos\web\clientAsync) that shows how to use it. Once you get data from the client, you can put it in the dataset using SetJsonData and then you can call Open to iterate through the dataset.

But honestly, if you want to bind your data manually to a control, I don't see a need for the dataset. Just get the data from the server using TXDataWebClient, and build your grid directly using the retrieved objects.