Topic: Limiting records display on tGrid

I come across an older post inquiring about db speed.


Dmitry's advice was to reduce quantity of records to display on tGrid where there are 1000s of records to be displayed. I'm thinking it's very useful and something should be included with all db apps where expected records could be 1000s.

begin
Form1.KeyPreview := True;  // If KeyPreview is true, keyboard events occur on the form before they occur on the active control.
Form1.TableGrid1.dbLimit := 500;
end.

Couple of questions:

♦ In the script above "KeyPreview" is a system syntax or to be used on a the form with a component such as button?
♦ What happens after scrolling 500 (in this case, according to script above) records? Is next batch of 500 records loaded automatically in tGrid?

Adam
God... please help me become the person my dog thinks I am.

Re: Limiting records display on tGrid

KeyPreview
Specifies whether the form should receive keyboard events before the active control.
If KeyPreview is true, keyboard events occur on the form before they occur on the active control.
If KeyPreview is false, keyboard events occur only on the active control.


KeyPreview does not have any relationship to limit for records.


What happens after scrolling 500 (in this case, according to script above) records? Is next batch of 500 records loaded automatically in tGrid?

No, it's not support. But I think it's possible to implement it using script.

Dmitry.

Re: Limiting records display on tGrid

Thank you very much Dmitry......................


No, it's not support. But I think it's possible to implement it using script.

Could you please provide a sample project with script you mentioned?
It'd be great if sample project db contains more than 1000 records.


Would it be possible to get full totals on tGrid footer when displaying/loading limited amount of records rather than just displayed/loaded records total. By tGrid totals  I mean desired/specified tGrid column/s totals on tGrid footer?

Adam
God... please help me become the person my dog thinks I am.

Re: Limiting records display on tGrid

An example for you
https://www.dropbox.com/s/6y49rp04l8f83 … e.zip?dl=0

Dmitry.

Re: Limiting records display on tGrid

Hi Dmitry,


Great support. Thank you very much.........
Truly appreciated................


For numbers columns (footer all records salary total) I have added a salary column to the sample project you have kindly supplied for testing purposes.
I have added the SUM line to the script but didn't work?

procedure Form1_GridEmployees_OnChange (Sender: TObject);
begin
    Form1.GridEmployees.Columns[0].Footer.Caption := SQLExecute('SELECT COUNT(id) FROM employees');
    Form1.GridEmployees.Columns[4].Footer.Caption := SQLExecute('SELECT SUM(id) FROM employees');
end;
Adam
God... please help me become the person my dog thinks I am.

Re: Limiting records display on tGrid

It should work, please upload the project to dropbox or on similar service, I will check.

Dmitry.

Re: Limiting records display on tGrid

Adam,
It looks like you are trying to sum the id instead of the salary.


Form1.GridEmployees.Columns[4].Footer.Caption := SQLExecute('SELECT SUM(id) FROM employees');

It should be

Form1.GridEmployees.Columns[4].Footer.Caption := SQLExecute('SELECT SUM(salary) FROM employees');

8 (edited by AD1408 2017-11-15 19:48:14)

Re: Limiting records display on tGrid

Hi EHW,


That works. Why I was trying to get sum of salary ID is unknown to me. I guess my one cell brain couldn't work it out correctly.
Thank you very much.......
Truly appreciated..............

Adam
God... please help me become the person my dog thinks I am.