1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| TFormHistorique.RxDBGrid1TitleClick(Column: TColumn);
var
EstPresent:Integer;
ASC,DESC:Boolean; // ASC : triascendant DESC descendant
begin
// rechercher si déja un tri dans la requete
ASC:=NPos('ASC',DmSQL.SQLHistorique.SortedByText.text,1)<>0;
DESC:=NPos('DESC',DmSQL.SQLHistorique.SortedByText.text,1)<>0;
DmSQL.SQLHistorique.SortedByText.Clear;
// Il y déja un tri ASC je code donc un tri DESC
if ASC and not DESC then
DmSQL.SQLHistorique.SortedByText.Add(Column.FieldName+' DESC');
// Il y déja un tri ADESC je code donc un tri ASC
if not ASC and DESC then
DmSQL.SQLHistorique.SortedByText.Add(Column.FieldName+' ASC');
// Aucun tri je code donc un tri ASC
if not ASC and not DESC then
DmSQL.SQLHistorique.SortedByText.Add(Column.FieldName+' ASC');
DmSQL.SQLHistorique.Sort;
end; |
Partager