Hi,
I'm trying to implement filter search in the grid
This is the code:
private void OnFilterByTextCommand(string parameter)
{
var compositeDescriptor = new CompositeFilterDescriptor
{
LogicalOperator = FilterCompositionLogicalOperator.Or
};
foreach (GridViewColumn column in RadGrid.Columns)
{
var dataColumn = column as GridViewDataColumn;
if (column == null) continue;
object obj = null;
try
{
if (dataColumn != null)
obj = Convert.ChangeType(parameter, dataColumn.DataType);
}
catch
{
continue;
}
if (obj == null) continue;
FilterOperator op = dataColumn.DataType.IsValueType ? FilterOperator.IsEqualTo : FilterOperator.Contains;
FilterDescriptor filterDescriptor = new FilterDescriptor
{
IsCaseSensitive = false,
Member = dataColumn.UniqueName,
Operator=op,
Value=obj
};
compositeDescriptor.FilterDescriptors.Add(filterDescriptor);
}
RadGrid.FilterDescriptors.Add(compositeDescriptor);
}
I get exception in the columns that the column type is not the same as the
Item source collection in this binding member
If I bind the column to same data type and us one of this data properties
The exception is cant cast beaten the types
Someone know this problem?
Maybe I need to change the filter method?
Best Regards
Ehud