delphi DbGridEh資料進行升序降序排序
//傳入升序引數
procedure TfmJcDjMxBase.mnuDxMainAscClick(Sender: TObject);
begininherited;
GetMainDataSort('1') ;
end;
//傳入降序引數
procedure TfmJcDjMxBase.mnuDxMainEescClick(Sender: TObject);
begin
inherited;
GetMainDataSort('2') ;
end;
//實現方法
procedure TfmJcDjMxBase.GetMainDataSort(sortMode:String='1' ) ;
var
strSql,strSort,strDJBH:String ;
ClientDataSet1:TClientDataSet;
iPos:Integer ;
begin
if FOperate=MC_BROWSE then
begin
try
if dxMain.FieldByName(grdMain.Columns[FSelCol].FieldName).FieldKind=fkData then
begin
dxMain.IndexFieldNames :='' ;
dxMain.IndexDefs.Clear;
if sortMode='1' then
dxMain.IndexDefs.Add('dxMainIndex'+grdMain.Columns[FSelCol].FieldName+sortMode,grdMain.Columns[FSelCol].FieldName,[])
else
dxMain.IndexDefs.Add('dxMainIndex'+grdMain.Columns[FSelCol].FieldName+sortMode,grdMain.Columns[FSelCol].FieldName,[ixDescending]) ;
dxMain.IndexName:='dxMainIndex'+grdMain.Columns[FSelCol].FieldName+sortMode;
end ;
except
;
end ;
end;
end ;
//DbGridEh新增的方法
procedure TfmJcDjMxBase.grdMainTitleClick(Column: TColumnEh);
begin
inherited;
FSelCol:=column.Index;
//這是寫的兩個popupmenu的按鈕呼叫
end;