RadGridView filtered items and MVVM

2 posts, 0 answers
  1. Sebastian
    Sebastian avatar
    16 posts
    Member since:
    Jun 2010

    Posted 03 Nov 2011 Link to this post

    Hi,

    I currently searched the forums for information about how to retrieve the collection of filtered data from a RadGridView. I found a solution using the Items property of the GridView to access to currently filtered items (and i do not use paging ;)).

    The problem is, that we try to use MVVM whenever possible. So is there a proper solution to access the filtered items without binding the model to the ui (the grid view in special) at this point ? If i try a two-way binding i always get a xaml exception from the Items property.

    Kind regards
    Sebastian
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2477 posts

    Posted 07 Nov 2011 Link to this post

    Hello Sebastian,

    You can't two-way bind a property which is read-only.

    What you can do is bind your grid to an instance of QueryableCollectionView residing in your view model. This instance will at all times represent the current view of data, i.e. what the user sees in RadGridView.

    So, instead of binding the grid to your sourceCollection, you will create a QueryanleCollectionView(sourceCollection), expose it as a property on your view model and then bind the grid to this new property. Enumerating this QueryanleCollectionView instance will provide you with all items that are currently in view. 

    I hope this helps.

    Kind regards,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top