Completed
Last Updated: 15 Aug 2017 11:03 by ADMIN
ADMIN
Hristo
Created on: 24 May 2017 12:19
Category: GridView
Type: Bug Report
2
FIX. RadGridView - changing the operator of an IsNull or IsNotNull filter to Equals should remove the filter from the grid
How to reproduce: Check the attached video --> radgridview-filtering.gif

Workaround:
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        this.radGridView1.DataSource = this.GetData();
        this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

        this.radGridView1.EnableFiltering = true;
        this.radGridView1.FilterChanging += RadGridView1_FilterChanging;
        this.radGridView1.FilterChanged += RadGridView1_FilterChanged;
    }

    private void RadGridView1_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
    {
        if (clearFiler)
        {
            this.radGridView1.FilterDescriptors.Remove((FilterDescriptor)e.NewItems[0]);
            clearFiler = false;
        }
    }

    bool clearFiler = false;
    private void RadGridView1_FilterChanging(object sender, GridViewCollectionChangingEventArgs e)
    {
        if (e.PropertyName == "Operator" && e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanging)
        {
            FilterDescriptor fd = e.OldItems[0] as FilterDescriptor;
            if (fd != null && (fd.Operator == FilterOperator.IsNull || fd.Operator == FilterOperator.IsNotNull))
            {
                clearFiler = true;
            }
        }
    }
    private object GetData()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Id", typeof(int));
        dt.Columns.Add("Name", typeof(string));
        dt.Columns.Add("Date", typeof(DateTime));
        dt.Columns.Add("Bool", typeof(bool));

        for (int i = 0; i < 100; i++)
        {
            dt.Rows.Add(i, "Name " + i, DateTime.Now.AddDays(i), i % 2 == 0);
        }

        return dt;
    }
}
0 comments