DBGridEh结合ClientDataSet排序

var
  OldIndex: string;

begin

    OldIndex:= cds.IndexName;
    if OldIndex <> '' then
    begin
      cds.IndexName:= '';
      cds.DeleteIndex(OldIndex);
    end;
    case Column.Title.SortMarker of
      smNoneEh,
      smUpEh  :
      begin
        cds.AddIndex('px', NewIndex, [ixDescending]);
        Column.Title.SortMarker:= smDownEh;
      end;
      smDownEh:
      begin
        cds.AddIndex('px', NewIndex, [ixPrimary]);
        Column.Title.SortMarker:= smUpEh;
      end;
    end;
    cds.IndexName:= 'px';
end

你可能感兴趣的:(client)