三层结构中DBGridEh实现点击列Title排序

At first you need to define index for every column that you want to sort:

1w:in IDE

    double click your ClientDataSet's IndexDefs property,Add new,set "Name""Fields""DescFields" value
    (for example:equal to column name)

2w:in code

  with dataset.IndexDefs do
  begin
    Clear;
    with AddIndexDef do
    begin
      Name:='your column name';
      Fields:='your column name';
      DescFields:='your column name';
  end;

Then write code in DBGridEh OnTitleClick:

  case Column.Title.SortMarker of
    smNoneEh:
    begin
      Column.Title.SortMarker := smDownEh;
      fTagStateSetDM.cdsData.IndexName:=Column.FieldName;
    end;
    smDownEh:
    begin
      Column.Title.SortMarker := smUpEh;
      fTagStateSetDM.cdsData.IndexFieldNames:=Column.FieldName;
    end;
    smUpEh:
    begin
      Column.Title.SortMarker := smDownEh;
      fTagStateSetDM.cdsData.IndexName:=Column.FieldName;
    end;
  end;

阅读更多
文章标签: ide
个人分类: Delphi
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

三层结构中DBGridEh实现点击列Title排序

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭