Problem with GridViewDataColumn Filter

4 posts, 0 answers
  1. Denis
    Denis avatar
    16 posts
    Member since:
    Mar 2012

    Posted 14 Mar 2013 Link to this post

    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).
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 15 Mar 2013 Link to this post

    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.

  3. Denis
    Denis avatar
    16 posts
    Member since:
    Mar 2012

    Posted 15 Mar 2013 Link to this post

    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.
  4. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 15 Mar 2013 Link to this post

    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.

Back to Top