Speeding Up
EWB TDataset Operations
March 23, 2023
Sometimes you will have a LOT of data in a TDataset on your web client and want to do bulk operations
and may find the app sluggish. Don't despair.
For example, you may want to calculate an average, or maximum
or want to set a new field such as an Image/icon if a field is set a certain
way for the primo user experience. Oh, another
good reason is that there are few GOOD ways to set colours
of cells in TGrids that also survive user sorts.
A good EASY way is to set a secondary HTML-type field that the client application
can set from server data that can contain colours as
well as text, images, etc.
The easiest way to do all these things is to cycle through
the TDataset after loading from the server and
setting the new field.
But if you have a large TDataset
with, say, 10,000 or 20,000 items, it will be slow because every update causes
EWB to want to inform your TGrid and other components
on each change. It can easily take 10 second or more, or even cause
timeout warnings.
Or you may use it if you wish to create a subset TDataset based on search criteria as the user is typing.
The trick is to call. dataset.DisableControls
before cycling through them, and then call dataset.EnableControls
when you are done with your processing. It will be super fast, usually
almost instantaneous if you optimize your code!
Copyright © 2023, Erick Engelke