Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Grids and Datasets
Wed, Oct 10 2018 4:52 PMPermanent Link

Mario Enríquez

Open Consult

Hi Folks,

One question regarding Datasets and how they interact when bound to a TGrid..

If a Dataset has, let says 1,000 records and it is bound to a TGrid that only has 10 visible rows. Are the 1000 records loaded into the grid or is there some smart caching magic going in order to optimize memory, etc?

Regards,
Mario
Fri, Oct 12 2018 7:08 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

Mario

All the rows that are requested when LoadRows is executed are downloaded.
You can limit the amount of rows by defining parameters when the datasets are created.
You can also use the RANGE clause of the SELECT statement to limit the number of rows returned to a specified range which allows you to setup pages of rows to view.

Richard

Dataset definition example
-----------------------------------
SELECT
  Category, Number, StockNumber,
  1 AS Cnt,
  Identity, ITR, Description, OEM, Qty, Berco, SellPrice, Location
FROM Stock S1
WHERE
   Category = {Category='ADR'} AND
   Identity LIKE {Identity='%'} AND
   Description LIKE {Description='%'} AND
   Berco LIKE {Berco='%'} AND
   OEM LIKE {OEM='%'} AND
   ITR LIKE {ITR='%'} AND
   Location LIKE {Location='%'} AND
   Qty BETWEEN {QtyMin=0} AND {QtyMax=999999}
 ORDER BY S1.Category, S1.Number


Defining parameters in EWB application
-----------------------------------------------------
procedure TfmMenu.SetFilter;
begin
  esStockSummary.Params.Clear;
  esStockSummary.Params.Add('Category=' + QuotedStr(esStockCategories.Columns['ID'].AsString));

  if edIdentity.Text > ''
     then esStockSummary.Params.Add('Identity=' + QuotedStr('%' + edIdentity.Text + '%'));
  if edDescription.Text > ''
     then esStockSummary.Params.Add('Description=' + QuotedStr('%' + edDescription.Text + '%'));
  if edBerco.Text > ''
     then esStockSummary.Params.Add('Berco=' + QuotedStr('%' + edBerco.Text + '%'));
  if edOEM.Text > ''
     then esStockSummary.Params.Add('OEM=' + QuotedStr('%' + edOEM.Text + '%'));
  if edITR.Text > ''
     then esStockSummary.Params.Add('ITR=' + QuotedStr('%' + edITR.Text + '%'));
  if edLocation.Text > ''
     then esStockSummary.Params.Add('Location=' + QuotedStr('%' + edLocation.Text + '%'));
  if edQtyMin.Text > ''
     then esStockSummary.Params.Add('QtyMin=' + edQtyMin.Text);
  if edQtyMax.Text > ''
     then esStockSummary.Params.Add('QtyMax=' + edQtyMax.Text);

  ShowProgress('Loading stock items');
  Database.LoadRows(esStockSummary);
end;
Sat, Oct 13 2018 6:15 AMPermanent Link

Uli Becker

Richard,

> All the rows that are requested when LoadRows is executed are downloaded.
> You can limit the amount of rows by defining parameters when the datasets are created.

True, but that wasn't his question.
TGrid is virtual, so there is no problem to handle 1000 records.

Though I agree that generally it doesn't make sense to load such a big
number of records.

Uli

Sun, Oct 14 2018 1:06 PMPermanent Link

Mario Enríquez

Open Consult

Thank you very much Richard and Uli,

Nice tip on the RANGE trick to make paging easier on the client side, because I've not figure out how to go around this subject yet.

On the DataSet/Grid question, just wanted to made sure there was a real advantage on using a TDataSet instead on loading the returned records manually into the grid, because I get standard JSON collections from the Webservice, instead of the {rows[]} format required for the EWB dataset.

Regards.
Mario
Image