TDBAdvGrid, sorting problems

Hi TMS team,


I have a problem with the sorting in the TDBAdvGrid. Here is my setup. My grid is linked to a TMyDataSource (TMyQuery) and this query is sort by the "IndexFieldNames" property. My data are on a MySQL Server.

I take a look at the demo project "\TMS VCL UI Pack Demos\DBAdvGrid\CDSSort" and I want to use the bottom method to sort my query.
In the event "OnCanSort" of the grid, I change the "IndexFieldNames" of the query but the grid doesn't refresh. I try to add a "TMyQuery.First" and it doesn't work.
I add "grid.Reload" at the end of the event and it works.

But in the demo project, it don't need to add this code for the grid to sort.

Can you explain me why ?

Thanks

Did you set DBAdvGrid.PageMode = true?

Hi Bruno,

I just try it and it works, but I have another issue.

I need the option "DBAdvGrid.PageMode = False", because I have a selection in this grid (DisjunctRowSelect). Is there any solution for this ?

If grid.PageMode = false, the grid will perform an internal sort and no other actions are needed. In this case, you should NOT implement OnCanSort and do operations on the dataset.

oki, I understand that, but my Query is huge and the internal sort is slower than changing my indexfieldnames of my query.

Is there anything I can do ?

If you really want to sort via the dataset, then you should set grid.PageMode = true.