[Lazarus] db grid/dataset components that only load currently visible records?

Michael Van Canneyt michael at freepascal.org
Thu Feb 23 17:16:00 CET 2023



On Thu, 23 Feb 2023, Luca Olivetti via lazarus wrote:

> El 23/2/23 a les 13:52, Michael Van Canneyt via lazarus ha escrit:
>> 
>> 
>> On Thu, 23 Feb 2023, Luca Olivetti via lazarus wrote:
>> 
>>> El 23/2/23 a les 11:11, Michael Van Canneyt via lazarus ha escrit:
>>>> But IMO: in the first place you should ask yourself if displaying 10.000 
>>>> records is
>>>> what you actually want to do.
>>> 
>>> No, I just need to display 20 or so records, the problem is I'd like the 
>>> user to be able to scroll over the whole table, so I'd have to hook a lot 
>>> of events in the TDBGrid (if that's even possible, otherwise I'd have to 
>>> implement a replacement) and get rid of the TDBNavigator and implement a 
>>> custom one in its place.
>> 
>> The LCL could do with a pager component. Seems to be standard when Web 
>> pages
>> display grids/tables, so users should be used to it :-)
>
> Even if such a component existed, I don't think it would fit my use-case.

Why do you think so ? Paging is exactly what you want to do.

> Maybe I should just write a TDataset descendant tailor made for this 
> application, any pointer on how to write a minimal descendant?
> I'm looking at the TMemDataset implementation as an example, is it a good 
> one?

As good as any other.

> The idea is to substitute open and scrolling (next/prior/locate/etc.) with 
> the appropriate sql statements to just retrieve a small buffer of data around 
> the current record (I can do that easily enough), though I'm not sure that 
> would be enough to fool the TDBGrid.

I don't know what the grid exactly does, so I cannot advise.

Michael.


More information about the lazarus mailing list