用GridEh,clientdataset 排序的问题!
如何实现点击标题升降序?

解决方案 »

  1.   

    clientdataset本身就能排序的 点那个标题就用clientdataset排序下
      

  2.   

    clientdataset有好像没有sort这个属性
      

  3.   

    对,TClientDataSet没有Sort属性,可以通过设置IndexFieldNames等属性来排序
      

  4.   

    既然和GRID关联,直接在GRID上排序就行了(难道GridEh不是默认就支持点标题排序的吗?)
      

  5.   

    设置dbGridEh里需要排序的字段的Title->Titlebutton属性为true;
    设置dgGridEh的optionsEh->dbhautoSortMarking属性为true;
    在dbGridEh的ontitleButtonClick事件里面判断。procedure Tfrmmain.dbgGridEh1TitleBtnClick(Sender: TObject; ACol: Integer;
      Column: TColumnEh);
    begin
      if column.Title.SortMarker=smdowneh then
        ClientDataSet1.IndexFieldNames := column.FieldName
      else
        ClientDataSet1.IndexFieldNames := column.FieldName +' DESC';
    end;
      

  6.   

    路过学习,很少用到 clientdataset,一般都是用 AdoQuery
      

  7.   


    用这个测试不通过,提示“没有column.FieldName DESC” 这个字段
      

  8.   


    楼主 GridEh 换成 cxGird 保证你不用写一句代码  
    各个字段的排序功能都有  控件本身就实现了