Search in multiple columns

Hi:

Is it possible to express "Column A is like '*ABC*' OR Column B is like '*ABC*'" using RecordFilters? See the following code - I'm trying to search for a pattern in all columns.

this.grid.TableDescriptor.RecordFilters.Clear();
for (int i = 0; i < this.grid.TableDescriptor.Columns.Count; i++)
{ this.grid.TableDescriptor.RecordFilters.Add(new RecordFilterDescriptor(this.grid.TableDescriptor.Columns[i].MappingName,
FilterLogicalOperator.Or, new FilterCondition[] { new FilterCondition(FilterCompareOperator.Like, "*ABC*") }));
}
}

But it seemed the criteria are applied as "AND" conditions - if I only use the column that actually contains the text it works, but whenever i include a second column that doesn't contain the text i get empty result.

1 Reply

HA Haishi July 10, 2007 11:43 PM UTC

To answer myself, use

this.grid.TableDescriptor.RecordFilters.LogicalOperator = FilterLogicalOperator.Or;

The FilterLogicalOperator.Or in original code specifies the logical operation among the FilterCondition[], while this statment controls how the RecordFilterDescriptors are conjuncted.

Loader.
Up arrow icon