Refresh Column Filter

4 posts, 0 answers
  1. Tim
    Tim avatar
    114 posts
    Member since:
    Aug 2011

    Posted 25 Jul 2012 Link to this post

    Hello telerik,

    I have a table that is displaying some data and I want NOT to show the row if one of the columns is zero. So I thought that this is really easy. I just added a filter like this
    Telerik.Windows.Controls.GridViewColumn countColumn = this.treeListView.Columns["countColumn"];
    Telerik.Windows.Controls.GridView.IColumnFilterDescriptor countFilter = countColumn.ColumnFilterDescriptor;
     
    countFilter.SuspendNotifications();
    countFilter.FieldFilter.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsNotEqualTo;
    countFilter.FieldFilter.Filter1.Value = 0;
                 
    countFilter.ResumeNotifications();

    and it worked! Perfect! But now I am able to change the data that gets displayed in this table. If that happens, of course, the filter should be reapplied or because I never told the filter to deactivate itself it should update automatically. Ok, that's not the case but how to do the update? I tried to reapply the filter, I tried to remove the filter and add it again, I tried the Refresh method... Nothing is working - or not working well. Reapplying the filter causes some weird behavior - I guess this is because the data is not yet in the visual tree (???) - for example: Data displayed is ok - now I change the data - filter is reapllied - Zero values still visible - if I now scroll down, they suddenly disappear... This is really awful! How can I achieve such behavior in a simple and clean way? It is possible, right?

    A big thanks for any hints and ideas and help,
    Tim.



  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Jul 2012 Link to this post

    Hi Tim,

     May I ask you whether you have edited the item as suggested in this help article? How do you currently edit the item? 

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Tim
    Tim avatar
    114 posts
    Member since:
    Aug 2011

    Posted 26 Jul 2012 Link to this post

    Hi Didie,

    thanks for your reply! I am not using the way the article suggests as I am using the MVVM pattern. Don't want to bother the GridView itself. And there is another reason. My table has hundreds or even thousands of data items and they will be changed ALL! I don't think the performance will be great doing it that way... Other ideas?

    Thanks a lot!
    Tim.
  5. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 26 Jul 2012 Link to this post

    Hi,

    RadGridView cannot subscribe to the PropertyChanged event of hundreds and thousands of items since this will lead to a massive total overkill performance wise.

    The filter will be automatically re-applied when the source collection that the grid is bound to raises the CollectionChanged event. If the Action is Reset, the grid will re-create its entire view. It the Action is Add or Remove with a single item, the grid will decide what to do with this item (i.e. whether it passes the current filter) and place it where it need to go. So one way of doing what you want is to remove a data item, edit its Value property and then add it back again.

    The other way is to let the grid know that you are doing something on the data item by following the article that mu colleague suggested. You can always use some kind of attached behavior in order to maintain your MVVM pattern.

    The bottom line is that the grid need to be informed in some way that something is changing since it cannot afford to subscribe to the PropertyChanged event of all its items. This decision was intentionally taken and this behavior is by design.

    Greetings,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top