cxgrid过滤使用心得

uses cxFilter;

cxgrid过滤条件清除:cxgrdbtblvwGrid1DBTableView2.DataController.Filter.AutoDataSetFilter:=True;
                                     cxgrdbtblvwGrid1DBTableView2.DataController.Filter.Clear;
cxgrid过滤条件添加:cxgrdbtblvwGrid1DBTableView2.DataController.Filter.Root.Clear;

cxgrdbtblvwGrid1DBTableView2.DataController.Filter.Root.AddItem(cxgrdbtblvwGrid1DBTableView2.GetColumnByFieldName('合同号'),folike,'%'+hth+'%','%'+hth+'%');
cxgrdbtblvwGrid1DBTableView2.DataController.Filter.Active:=True ;

CXGRID程序控制过滤方法:
DBTable.DataController.Filter.Root.Clear;
// DBTable.DataController.Filter.Root.BoolOperatorKind过滤关系【有四个值】
DBTable.DataController.Filter.Root.BoolOperatorKind:= fboOR;//或者
DBTable.DataController.Filter.Root.BoolOperatorKind:= fboAND;//并且
DBTable.DataController.Filter.Root.BoolOperatorKind:= fboNOTOR;//非或者
DBTable.DataController.Filter.Root.BoolOperatorKind:= fboNOTAND;//非并且
//DBTable.DataController.Filter.Root.AddItem(AItemlink:Tobject;Aoperatorkind:Tcxfilteroperator;Const Avalue:variant;const Adisplayvalue:STRING);

相应说明:
AItemlink=列
Aoperatorkind=条件
foequal        等于
fonotequals        不等于
foless        小于
folessequal        小于等于
fogreater        大于
fogreaterequal        大于等于
oflike        相似
ofnotlike        不相似
    ofblank        为空
    ofnotblank        不为空
Avalue=条件值
Adisplayvalue=显示值
DBTable.DataController.Filter.Active:=TRUE;

//由上面可得出一个过程:
PROCEDURE DATA_ADDITEM(CXDATA:TcxGridDBDataController;Index,IfInt:integer;VarStr,PlaStr:String);
Var IfStr:TcxFilterOperatorKind;
Begin
  Case IfInt Of
      0: IfStr:= foEQUALS;
      2: IfStr:=foNOTEQUALS;
      3: IfStr:=foLESS;
      4: IfStr:=foLESSEQUAL;
5: IfStr:=foGREATER;
      6: IfStr:=foGREATEREQUAL;
      7: IfStr:=ofLIKE;
      8: IfStr:=ofNOTLIKE;
      9: IfStr:=ofBLANK;
      10:IfStr:=ofNOTBLANK;
  End;
CXDATA.ROOT.AddItem(CXDATA.Columns[Index],IfStr,VarStr,PlaStr)
End;

uses cxFilter;



      with cxGridDBBandedTableView.DataController.Filter do
        begin
          Root.Clear;
          Root.AddItem(cxGridDBBandedTableView.GetColumnByFieldName('操作员姓名'), foLike, '%' + Trim(cxTextEdit.Text) + '%', '%' + Trim(cxTextEdit.Text) + '%');
          Active := True;
        end;

设置过滤的案例:
<AGridView>.DataController.Filter.AddItem(nil, <AOrderDateColumn>, foEqual, '5/25/1988', '5/25/1988');
To enable/disable filtering via code set the GridView's DataController.Filter.Active property to True.
	
[Delphi]Open in popup window
<AGridView>.DataController.Filter.Active := False;


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值