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

Problem with GridViewDataColumn Filter

3 Answers 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Denis
Top achievements
Rank 1
Denis asked on 14 Mar 2013, 08:24 AM
Hello telerik team and members,
In my project I'm using Telerik controls 2012.3 version with hotfixes (2012.3.1404.40).
Recently, I faced up with problem in RadGridView filtering. I need to set filter from code and change filter settings from UI at the same time. For this I wrote behavior which apply filter when GridViewDataColumn.Loaded event is raised.
private void FilterColumn()
{
    AssociatedObject.ColumnFilterDescriptor.SuspendNotifications();
  
    AssociatedObject.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = FilterOperator.IsGreaterThan;
    AssociatedObject.ColumnFilterDescriptor.FieldFilter.Filter1.Value = 4;
              
    AssociatedObject.ColumnFilterDescriptor.ResumeNotifications();
}
And it works fine: filter is active and items are filtered (all_ok.jpg). But if I reloaded underlying collection, filter become inactive and items are no longer filtered(broken_filter.jpg).
What can be cause of that strange filter behavior? Can it be more convenient way to control RadGridView filter both from code and from UI?
I prepared test project. (To reproduce this problem you should click Refresh button 2 times: one to populate GridView, and the second to reload data).

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 15 Mar 2013, 11:16 AM
Hello,

For some reason we were unable to download the sample project from the link provided.

Can I ask you to please open a new support ticket and attach the sample project there.

Thanks in advance.

Regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Denis
Top achievements
Rank 1
answered on 15 Mar 2013, 01:40 PM
Hello, Rossen Hristov

I uploaded project in other place. Here is the link.
ps. But it can be possible to download project by previous link too. I checked several times.
0
Rossen Hristov
Telerik team
answered on 15 Mar 2013, 01:50 PM
Hello,

The filter disappears because you set the ItemsSource to null. When someone sets the ItemsSource of the grid to null we have to clear all descriptors. If you directly assign a new ItemsSource whose generic type is compatible with the generic type of the old ItemsSource (i.e. it is the same class or a sub-class) we will detect this and keep the descriptors in place because we can be sure that they will be valid for the new ItemsSource as well.

If you delete this line, the filter will remain in place:

//Items = null;

Alternatively, if you really need to set it to null before assigning the new items source, you would have to make sure that you execute the filtering logic again so that the column is filtered again.

All the best,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Denis
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Denis
Top achievements
Rank 1
Share this question
or