zoukankan      html  css  js  c++  java
  • GridLookUpEdit多列模糊查询最简单方式 z

    GridLookUpEdit的知识库是RepositoryItemGridLookUpEdit,切确的说GridLookUpEdit只是RepositoryItemGridLookUpEdit的一个壳而已,
    这也就是在GridControl的GridView中,对列绑定的是RepositoryItemGridLookUpEdit而不是GridLookUpEdit的原因,RepositoryItemGridLookUpEdit才是GridLookUpEdit的核心,所以处理这个过滤操作,其实就是对RepositoryItemGridLookUpEdit进行操作,
    方法的参数也是RepositoryItemGridLookUpEdit类型,这样在GridView中使用RepositoryItemGridLookUpEdit也可以直接调用。eg:

    SetGridLookUpEditMoreColumnFilter(gridLookUpEdit1.Properties);
    SetGridLookUpEditMoreColumnFilter(repositoryItemGridLookUpEdit1);
    /// <summary>
            /// 设置GridLookUpEdit多列过滤
            /// </summary>
            /// <param name="repGLUEdit">GridLookUpEdit的知识库,eg:gridlookUpEdit.Properties</param>
            void SetGridLookUpEditMoreColumnFilter(DevExpress.XtraEditors.Repository.RepositoryItemGridLookUpEdit repGLUEdit)
            {
                repGLUEdit.EditValueChanging += (sender, e) =>
                {
                    this.BeginInvoke(new System.Windows.Forms.MethodInvoker(() => {
                        GridLookUpEdit edit = sender as GridLookUpEdit;
                        DevExpress.XtraGrid.Views.Grid.GridView view = edit.Properties.View as DevExpress.XtraGrid.Views.Grid.GridView;
                        //获取GriView私有变量
                        System.Reflection.FieldInfo extraFilter = view.GetType().GetField("extraFilter",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
    
                        List<DevExpress.Data.Filtering.CriteriaOperator> columnsOperators = new List<DevExpress.Data.Filtering.CriteriaOperator>();
                        foreach (GridColumn col in view.VisibleColumns)
                        {
                            if (col.Visible && col.ColumnType == typeof(string))
                                columnsOperators.Add(new DevExpress.Data.Filtering.FunctionOperator(DevExpress.Data.Filtering.FunctionOperatorType.Contains,
                                    new DevExpress.Data.Filtering.OperandProperty(col.FieldName),
                                    new DevExpress.Data.Filtering.OperandValue(edit.Text)));
                        }
    
                        string filterCondition = new DevExpress.Data.Filtering.GroupOperator(DevExpress.Data.Filtering.GroupOperatorType.Or, columnsOperators).ToString();
    
                        extraFilter.SetValue(view, filterCondition);
                        //获取GriView中处理列过滤的私有方法
                        System.Reflection.MethodInfo ApplyColumnsFilterEx = view.GetType().GetMethod("ApplyColumnsFilterEx", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                        ApplyColumnsFilterEx.Invoke(view, null);
                    }));
    
                };
    
            }
    
  • 相关阅读:
    javascript循环结构练习
    个人复习JavaScript重点(总结一)
    第十章汽车租凭系统
    员工执行
    第六章预习
    第五章使用Dictionary替换List<t>实现功能
    第5章体检套餐管理系统
    JAVA面试题
    AJAX
    SSM中的登陆验证码
  • 原文地址:https://www.cnblogs.com/zeroone/p/6250004.html
Copyright © 2011-2022 走看看