GridLookUpEdit多列模糊查询最简单方式 z
Posted zeroone
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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); })); }; }
以上是关于GridLookUpEdit多列模糊查询最简单方式 z的主要内容,如果未能解决你的问题,请参考以下文章
仿LookUpEdit多列模糊搜索,功能比GridLookUpEdit强大,比SearhLookUpEdit方便
Devexpress 中GridLookUpEdit的实现多列筛选问题。
请教gridLookUpEdit 多选之后,数据上不去,怎么回事??
dev 中 字符串转中文拼音缩写,对grid列表进行模糊匹配,grid获取焦点行,gridlookupedit控件用拼音模糊匹配下拉选项