折腾一天,你不按照demo里的代码来,就是没有效果。
procedure TUniGridsGroupingSorting.UniDBGrid1MultiColumnSort( Columns: TUniDBGridColumnArr; Directions: TUniSortDirections); var OrderStr : string; I : Integer; begin UniMainModule.ADOQuery5.Close;//必须在UniMainModule OrderStr := 'select * from [Customers]' + ' order by '; for I := Low(Columns) to High(Columns) do begin OrderStr := OrderStr + '['+Columns[I].FieldName+ '] '+IfThen(Directions[I], 'ASC', 'DESC')+','; end; OrderStr := RemoveTrailingChar(OrderStr, ','); UniMainModule.ADOQuery5.SQL.Text := OrderStr; UniMainModule.ADOQuery5.Open; end;
其二、点击列排序:
procedure TUniGridsColumnSort.SortColumn(const FieldName: string; Dir: Boolean); begin if Dir then ClientDataSet1.IndexName := FieldName+'_index_asc' else ClientDataSet1.IndexName := FieldName+'_index_des'; end; procedure TUniGridsColumnSort.UniDBGrid1ColumnSort(Column: TUniDBGridColumn; Direction: Boolean); begin SortColumn(Column.FieldName, Direction);//必须分开写调用 end;
看明白没,必须按这种格式,分开写。否则就是不行。作者没有说明why?再WEB中这处理的理由,你知道WHY?
标签:begin,end,unigui,18,UniMainModule,FieldName,OrderStr,GridsGroupingSorting,Column From: https://www.cnblogs.com/usegear/p/18002575