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

RadGridView filtered items and MVVM

1 Answer 154 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 03 Nov 2011, 03:13 PM
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

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 07 Nov 2011, 12:50 PM
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 >>

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