Removing all filterDescriptors programatically doesn't update columns distinct values

3 posts, 0 answers
  1. Michal
    Michal avatar
    9 posts
    Member since:
    Aug 2012

    Posted 01 Mar 2013 Link to this post

    Hello,

    Simply:

    I use this piece of code to clear all column filters user has apllied

    using (Events.ResultItems.DeferRefresh())
    {
         Events.ResultItems.FilterDescriptors.Clear()
    }

    The grid is refreshed properly, but when user had applied distinct value filter by checking the checkbox by it, after clearing the filters, the checkbox is still apllied, however no filters are active. How to refresh the "check state" of distinct values?
  2. Yoan
    Admin
    Yoan avatar
    1214 posts

    Posted 01 Mar 2013 Link to this post

    Hi Michal,

    Please check this help article for a reference. I believe it will be helpful for you.

    Greetings,
    Yoan
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Michal
    Michal avatar
    9 posts
    Member since:
    Aug 2012

    Posted 01 Mar 2013 Link to this post

    Thank you,

    I'll check it out

    EDIT

    So after little reading I found out the solution.

    using (Events.ResultItems.DeferRefresh())
                {
                    var filterDescriptors = EventsListViewModel.Events.ResultItems.FilterDescriptors;
                    foreach (var gridColumnFilter in filterDescriptors.OfType<ColumnFilterDescriptor>().ToList())
                    {
                        (gridColumnFilter as IColumnFilterDescriptor).DistinctFilter.Clear();
                        filterDescriptors.Remove(gridColumnFilter);
                    }
                }

    I need to prevent removing of programatically set filters, so I i filter FilterDescriptors to get only column types (those ae set by the user).
    The trick to refresh distinct values checkboxes was to clear distinct filters before removing the filter from the collection.
    I think it's a bug because removing the filters should update visual state of the controls (list of checkboxes)

    I attached 2 videos
    http://screencast.com/t/Jo57uFVPzxRY BAD using 1st v of code
    http://screencast.com/t/s6bE7GRIdI7U GOOD using my workaround
Back to Top