View Code
protected override string OnCreateLookupDisplayFilter(string text, string displayMember) { List<CriteriaOperator> subStringOperators = new List<CriteriaOperator>(); foreach (string sString in text.Split(' ')) { string exp = DevExpress.Data.Filtering.Helpers.LikeData.CreateContainsPattern(sString); List<CriteriaOperator> columnsOperators = new List<CriteriaOperator>(); foreach (GridColumn col in Columns) { if (col.Visible && col.ColumnType == typeof(string)) columnsOperators.Add(new BinaryOperator(col.FieldName, exp,BinaryOperatorType.Like)); } subStringOperators.Add(new GroupOperator(GroupOperatorType.Or, columnsOperators)); } return new GroupOperator(GroupOperatorType.And, subStringOperators).ToString(); }
修改成以下代码
View Code
protected override string OnCreateLookupDisplayFilter(string text, string displayMember) { List<CriteriaOperator> subStringOperators = new List<CriteriaOperator>(); foreach (string sString in text.Split(' ')) { List<CriteriaOperator> columnsOperators = new List<CriteriaOperator>(); foreach (GridColumn col in Columns) { if (col.Visible && col.ColumnType == typeof(string)) columnsOperators.Add(new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty(col.FieldName), sString)); } subStringOperators.Add(new GroupOperator(GroupOperatorType.Or, columnsOperators)); } return new GroupOperator(GroupOperatorType.And, subStringOperators).ToString(); }
以上代码来源官网论坛