TDBAdvGrid: Custom Sorting for ECO Expression Handles as DataSource

You can bind ECO Expression Handles to any grid in VCL.NET that supports TDataSource. This is one of the fab new features of RAD Studio 2007. TDBAdvGrid from TMS Software comes with some decent sort mechanisms. However, if you only want to load a subset of the complete data into the grid, which is handled by the PageMode property being set to True, you have to supply your customized sort event.

I wrote a very much generic sort routine for any expression handle being bound to the grid. I just have to investigate a bit more, if you can also use this approach for columns that you derive (aka calculate) in the expression handle. However, for a start, this is pretty generic and can be used in many cases and should get you started how TExpressionHandle handles sorting.

I use it in my CD Demo application e.g. to sort the album and song grid.

Above you see the implementation of the “<tt>OnCanSort</tt>” event of the grid. You need to make sure that sorting in general is being enabled using the <tt>SortSettings</tt> property. Be sure to read the manual which is provided before complaining the sorting does not work at all. There are some sophisticated possibilities with TDBAdvGrid and thus a lot of switched to set correctly.

blog comments powered by Disqus