我正在尝试实现telerik的RadGridView Silverlight控件的Search as you type功能。
如果我在GridView中有简单的GridViewDataColumn
,它工作正常。但是如果网格有除了它之外的列,它就会失败。
以下是代码段:
public CustomFilterDescriptor(IEnumerable<Telerik.Windows.Controls.GridViewColumn> columns)
{
this.compositeFilterDesriptor = new CompositeFilterDescriptor();
this.compositeFilterDesriptor.LogicalOperator = FilterCompositionLogicalOperator.Or;
try
{//tHIS throws the error
***foreach (GridViewDataColumn column in columns)
{
this.compositeFilterDesriptor.FilterDescriptors.Add(this.CreateFilterForColumn(column));
}
}***
catch
{
}
}
如何跳过不是GridViewDataColumn的列?
答案 0 :(得分:1)
事实证明这很简单。如果有人遇到类似的问题,这里修改了代码。
foreach (var column in columns)
{
if (column.GetType() == typeof(GridViewDataColumn))
{
this.compositeFilterDesriptor.FilterDescriptors.Add(this.CreateFilterForColumn(column as GridViewDataColumn));
}
}