![]() |
|
|
|
#1
|
|||
|
|||
|
Is this possible? I'm using TDbf for a small databasing app, and i want to be able to sort the data in a DBGrid by clicking on the titles. All the examples I've seen of sorting data in a DBGrid seem to be for apps using TQuery etc - whereas I dont have this component. I simply have:
TDbf -> DataSource -> DBGrid I take it that the datasorting will be something to do with the TDbf rather than anything else? Cheers --Tom |
|
#2
|
|||
|
|||
|
what backend ar eyou using? SQL based (MSSQL, Oracle, Interbase..), file based (Paradox, DBase, FoxPro...)...
|
|
#3
|
|||
|
|||
|
TDBF has the property IndexFieldName just as any TDataset descendent does. So, make sure all fields that are going to be sorted on, are indexed when you create your tables.
then use procedure TfrmMain.DBGrid1TitleClick(Column: TColumn); begin if Column.Index = 0 then MyTable.IndexFieldName:= ? else if Column.Index = 1 then MyTable.IndexFieldName:= ? etc etc end; You can sort tables based on more than one field, by separating the fields with a semicolon MyTable.IndexFieldName:= 'Field1;Field2'; If this helps, please accept as answer! Thanks! UnSysApps |
|
#4
|
|||
|
|||
|
Douglas thank you so much, I have been searching for this for ages!
One more thing though, is it possible to decide whether to sort Ascending or decending? Looking forward to your reply. |
|
#5
|
|||
|
|||
|
you create your tables.
![]() ![]()
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|