Alex
asked on
TMS DBADVGRID asc,desc the records
I have a tms dbadvgrid and i want when i click to the to a column header of a field to ascending or descending the records.How could i do this?
Go to the SortSettings property of the grid and set the property Show = true
You can even make it do it on more than one column at a time.
I think this is the property IndexShow = true under SortSettings as well as the first property I mentioned previously.
I think this is the property IndexShow = true under SortSettings as well as the first property I mentioned previously.
ASKER
hi mikelittlewood
i did that before ask this question but it does not do anything....
i did that before ask this question but it does not do anything....
hmm sec let me have a go.
Ive only done it with a normal AdvStringGrid and it works fine.
Ive only done it with a normal AdvStringGrid and it works fine.
ASKER
DBADVGRID has many differences with AdvStringGrid and other grids, it is a very complex component...
I wonder whether just because they have inherited the TDBAdvGrid from TAdvStringGrid, the properties are available, but because its linked directly to a query, it can't sort records.
The only thing I can suggest is possibly to trap the sort in the event onCanSort(), and rebuild your query based on which column header was clicked and the current stored direction.
I know it isnt exactly a nice job but its all I can think of.
Seems a bit pointless for the to have written code that cannot be used.
I'll have a look on the TMS component newsgroup and see if anyone else has made a comment on it.
I know it isnt exactly a nice job but its all I can think of.
Seems a bit pointless for the to have written code that cannot be used.
I'll have a look on the TMS component newsgroup and see if anyone else has made a comment on it.
Ok this way a reply to sorting not working for DBAdvGrid
Please see samples BDESort, ADOSort & DBAdvGrid PDF developers guide how to handle sort in a DBAdvGrid with PageMode = true
Please see samples BDESort, ADOSort & DBAdvGrid PDF developers guide how to handle sort in a DBAdvGrid with PageMode = true
ASKER
>>>Please see samples BDESort, ADOSort & DBAdvGrid PDF developers guide how to handle sort in a DBAdvGrid with PageMode = true
where i can find it?
where i can find it?
ASKER
or could you make me an example about this that you said before?
>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>
The only thing I can suggest is possibly to trap the sort in the event onCanSort(), and rebuild your query based on which column header was clicked and the current stored direction. .....
>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>
The only thing I can suggest is possibly to trap the sort in the event onCanSort(), and rebuild your query based on which column header was clicked and the current stored direction. .....
>>>>>>>>>>>>>>>>>>>>>>>>>>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
where i can find it?
Ill see if I can find it anywhere.
Ill see if I can find it anywhere.
ASKER
thanks a lot mikelittlewood i'll try this code tomorrow and i'll expecting you if you find the pdf.
Thank you again.
Thank you again.
I found their demo application for ADOSort, and would you believe, it doesn't work he he.
Their BDESort one worked but they came up with the same solution as what I gave you.
One thing that was different which I would use is to ignore the global variable I made and put this at the beginning of the code I provided
// disable internal sort
DoSort := False;
if dbadvgrid1.SortSettings.Di rection = sdAscending then
dbadvgrid1.SortSettings.Di rection := sdDescending
else
dbadvgrid1.SortSettings.Di rection := sdAscending;
// then put the rest of this
ADOQuery1.Close;
sortSQL := 'ORDER BY ' + DBAdvGrid1.Columns[ ACol].FieldName;
if dbadvgrid1.SortSettings.Di rection = sdDescending then
sortSQL:= sortSQL + ' DESC';
ADOQuery1.sql.text := cSQL + sortSQL;
ADOQuery1.Open;
One thing that was different which I would use is to ignore the global variable I made and put this at the beginning of the code I provided
// disable internal sort
DoSort := False;
if dbadvgrid1.SortSettings.Di
dbadvgrid1.SortSettings.Di
else
dbadvgrid1.SortSettings.Di
// then put the rest of this
ADOQuery1.Close;
sortSQL := 'ORDER BY ' + DBAdvGrid1.Columns[ ACol].FieldName;
if dbadvgrid1.SortSettings.Di
sortSQL:= sortSQL + ' DESC';
ADOQuery1.sql.text := cSQL + sortSQL;
ADOQuery1.Open;
ASKER
hahaha oh my god!!!!
they have the better components all over the world but they haven't any help this is unacceptable...
they have the better components all over the world but they haven't any help this is unacceptable...
I use the DBAdvgrid with ADO and sort and it works fine.
One thing you may need to check is that by default the TMS source has a conditional compile that excludes ADO, make sure that you remove/add this.
One thing you may need to check is that by default the TMS source has a conditional compile that excludes ADO, make sure that you remove/add this.
ASKER
thanks a lot mikelittlewood this is working fine.
Hi RickJ maybe with ado works but i work now with firebird and interbase components and it doesn't sort so easy only with some options it needs something like mikelittlewood code.
Thank you for the posts.
Hi RickJ maybe with ado works but i work now with firebird and interbase components and it doesn't sort so easy only with some options it needs something like mikelittlewood code.
Thank you for the posts.