Jump to content

TUniStringGrid Speed


RobYost

Recommended Posts

I read the topic:

https://unigui.wikispaces.com/How+to+improve+loading+time

 

and added the suggested lines.

    UniSession.AddJS('Ext.suspendLayouts()');
    UniSession.AddJS(gUnpaidCharges.JSName + '.store.suspendEvents();');
...

   UniSession.AddJS(gUnpaidCharges.JSName + '.store.resumeEvents();');
   UniSession.AddJS(gUnpaidCharges.JSName + '.view.refresh();');
   UniSession.AddJS('Ext.resumeLayouts(true)');

 

I timed the code and it goes through the code very fast (35ms)

 

But it takes 6 seconds for the grid to load.  It has about 50-60 lines in it.  It seems to take about the same amount of time to load with and without the suspendEvents added.

 

Do I have them entered wrong?

I also tried:

   UniSession.AddJS('Ext.suspendLayouts()');
   UniSession.AddJS('frmMain.fraTIncome.gUnpaidCharges.store.suspendEvents();');

...

   UniSession.AddJS('frmMain.fraTIncome.gUnpaidCharges.store.resumeEvents();');   
   UniSession.AddJS('frmMain.fraTIncome.gUnpaidCharges.view.refresh();');
   UniSession.AddJS('Ext.resumeLayouts(true)');
This is fast but it never redraws (The grid stays blank)
 
The main form is:
    frmMain
it has a frame on it:
    fraTIncome
it has a TUniStringGrid on it:
   gUnpaidCharges
 

Here is the slow code:

ds := CreateDataSet(sql);
  try
    gUnpaidCharges.RowCount := 1;
    gUnpaidCharges.RowCount := ds.RecordCount + 1;

    UniSession.AddJS('Ext.suspendLayouts()');
    UniSession.AddJS(gUnpaidCharges.JSName + '.store.suspendEvents();');

    while ds.EOF = False do
    begin
      curDue.Value := curDue.Value + ds.FieldByName('Amount').AsCurrency;
      gUnpaidCharges.cells[0, ds.RecNo] := fmtDate(ds.FieldByName('ChargeDate').AsDateTime);
      gUnpaidCharges.cells[1, ds.RecNo] := FmtCur(ds.FieldByName('Amount').AsCurrency);
      gUnpaidCharges.cells[2, ds.RecNo] := ds.FieldByName('Description').AsString; 
      gUnpaidCharges.cells[3, ds.RecNo] := IntToStr(DaysBetween(now, ds.FieldByName('ChargeDate').AsDateTime));
      gUnpaidCharges.cells[DUE_COL, ds.RecNo] := FmtCur(ds.FieldByName('AmountLeft').AsString);
      gUnpaidCharges.cells[6, ds.RecNo] := ds.FieldByName('Memo').AsString;
      gUnpaidCharges.cells[CID_COL, ds.RecNo] := ds.FieldByName('ChargeID').AsString;

      ds.Next;

      UniSession.AddJS(gUnpaidCharges.JSName + '.store.resumeEvents();');
      UniSession.AddJS(gUnpaidCharges.JSName + '.view.refresh();');
      UniSession.AddJS('Ext.resumeLayouts(true)');

    end;

  finally
    ds.Close;
    ds.Free;
  end;
Link to comment
Share on other sites

I had similar issues when starting out with UniGUI a few years ago. I think the UniStringGrid component is not optimised for large amounts of data, even 50/60 lines (do a forum search, I think Farshad commented to this effect).

 

The best plan is to use ClientDataSets instead of StringGrids.

Link to comment
Share on other sites

  • Administrators

I had similar issues when starting out with UniGUI a few years ago. I think the UniStringGrid component is not optimised for large amounts of data, even 50/60 lines (do a forum search, I think Farshad commented to this effect).

 

The best plan is to use ClientDataSets instead of StringGrids.

 

Fix for this problem is already available for a while.

 

Please see:

StringGrid Demo
Link to comment
Share on other sites

  • Administrators

 

I read the topic:

https://unigui.wikispaces.com/How+to+improve+loading+time

 

and added the suggested lines.

    UniSession.AddJS('Ext.suspendLayouts()');
    UniSession.AddJS(gUnpaidCharges.JSName + '.store.suspendEvents();');
...

   UniSession.AddJS(gUnpaidCharges.JSName + '.store.resumeEvents();');
   UniSession.AddJS(gUnpaidCharges.JSName + '.view.refresh();');
   UniSession.AddJS('Ext.resumeLayouts(true)');

 

I timed the code and it goes through the code very fast (35ms)

 

But it takes 6 seconds for the grid to load.  It has about 50-60 lines in it.  It seems to take about the same amount of time to load with and without the suspendEvents added.

 

Do I have them entered wrong?

 

Please try this:

  UniStringGrid1.BeginUpdate;
  try
    // make some big changes
  finally
    UniStringGrid1.EndUpdate;
  end;
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...