Completed
Last Updated: 13 Jun 2014 12:41 by ADMIN
ADMIN
Dimitar
Created on: 16 May 2014 10:22
Category: GridView
Type: Bug Report
0
FIX. RadGridView - Excel-like filtering when the grid is not bound and a column is filtered for the second time exception occurs.
To reproduce:
- Filer twice by a single column with Excel-like filtering.
- The second time InvalidCastException will occur.

Workaround:
- Create custom columns and override the GetDistinctValues method.

public class MyColumn : GridViewTextBoxColumn
{
    protected override GridViewColumnValuesCollection GetDistinctValues()
    {
        int index = this.Index;

        if (index >= 0)
        {
            GridViewColumnValuesCollection distinctValues = new GridViewColumnValuesCollection();
            foreach (GridViewRowInfo row in this.OwnerTemplate.Rows)
            {
               
                object cellValue = row.Cells[index].Value;
                if (!distinctValues.Contains(cellValue))
                {
                    distinctValues.Add(cellValue);
                }
            }
            if (distinctValues.Count > 0)
            {
                return distinctValues;
            }
        }

        return null;
    }
}

0 comments