ColumnSort
设置UniDGGrid点击表头时排序,设置方法比较麻烦且不通用,在实际开发中用处不大。
自己在项目中用了一个比较笨的办法,写了一个函数通过sql来排序:
procedure TMainForm.dbgRealtimeColumnSort(Column: TUniDBGridColumn;
Direction: Boolean);
var
sName: string;
bAll, bSort: Boolean;
begin
bSort := not dbgRealtime.TabStop; //正序或者倒序
bAll := rdbAllStcd.Checked;
//调用排序函数
ShowRealtimeSTCDForSort(bAll, WaterworksInfo.wwID, Column.Index+, bSort);
dbgRealtime.TabStop := not dbgRealtime.TabStop;
end; procedure TMainForm.ShowRealtimeSTCDForSort(AQureyAll: Boolean; ASTCD: string;
SortCol: Integer; Sort: Boolean);
var
sql: string;
nSort: Integer;
begin
nSort := Integer(Sort);
if AQureyAll then
begin
sql := Format('exec spGetSort 1, 0, %d, %d', [SortCol, nSort]);
end
else
begin
sql := Format('exec spGetSort 0, %s, %d, %d', [ASTCD,SortCol,nSort]);
end;
UniMainModule.DoQuery(sql, UniMainModule.qryRealtime);
SetRealtimeSTCDGrid;
end;