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

RadGridView - Accessing Filtered Data

2 Answers 494 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lou
Top achievements
Rank 1
Lou asked on 24 Jul 2019, 04:09 PM

I have a bit of a programming challenge…

We have a form that has a RadGrid whose itemsource is bound to collection.  That collection includes a Boolean field named ‘Selected’.
The form also has a ‘Select all’ button.

The user filters the grid based on customer, so it is displaying only 10 of the 50 items in the collection.

When they click the ‘Select all’ button, they want the items Selected property to be true for only the 10 records that are displayed in the grid.

If I can get a collection of just the rows displayed in the grid I could roll through both collections to locate matches.   I haven’t figured out a way to get the ‘filtered’ collection, and wonder if there is a more efficient way to accomplish the task.

Any ideas would be greatly appreciated.

Thanks in advance,
Lou

2 Answers, 1 is accepted

Sort by
0
Accepted
Dilyan Traykov
Telerik team
answered on 25 Jul 2019, 10:36 AM
Hello Lou,

The collection holding only the filtered items can be accessed via the RadGridView control's Items property. You can find more information about this in the Access Filtered and Sorted Items article.

Please give this a try and let me know if working with the Items property would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
1
Lou
Top achievements
Rank 1
answered on 25 Jul 2019, 03:57 PM

This is exactly what I needed Dilyan, thanks!

The page is a bit thin on details on how to use the Items collection, but it wasn't hard to figure out.   Since I am using WPF and not AJAX I don't have (or couldn't find) a reference to GridDataItem.   Instead I rolled through the items collection and cast it to the class that that the GrdResults.ItemsSource is a list of:

foreach (var x in GrdResults.Items)
{
        var dataItem = x as classnamegoeshere;
       // do cool stuff here using dataItem
}

Works perfectly.   Thanks so much!

Lou

Tags
GridView
Asked by
Lou
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Lou
Top achievements
Rank 1
Share this question
or