Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort DBGrid by clicking column's title

Well, this seems a little tricky (if not imposible). I'm trying to make my DBGrid sort its data by clicking on column's title.

The thing is that I'm (sadly) working with Delphi 3, I'm not using ADO DataSets and the query gets a lot of rows, thus I can't reopen my TQuery changing the order by clause on clicks.

Someone has implemented something like this?

like image 351
Eliseo Ocampos Avatar asked Oct 19 '25 19:10

Eliseo Ocampos


1 Answers

This is actually done by sorting the dataset, and then the grid reflects the change. It can be done easily enough by creating an index on the dataset field for that column. Of course, this can only be done on a dataset that supports index sorting, such as TClientDataset.

like image 190
Mason Wheeler Avatar answered Oct 21 '25 14:10

Mason Wheeler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!