This is a migrated thread and some comments may be shown as answers.

Removing all filterDescriptors programatically doesn't update columns distinct values

2 Answers 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michal
Top achievements
Rank 1
Michal asked on 01 Mar 2013, 10:09 AM
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 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 01 Mar 2013, 01:52 PM
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.

0
Michal
Top achievements
Rank 1
answered on 01 Mar 2013, 02:08 PM
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
Tags
GridView
Asked by
Michal
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Michal
Top achievements
Rank 1
Share this question
or