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

GridSearchBox - I need the filtered rows

4 Answers 316 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Graham
Top achievements
Rank 1
Veteran
Graham asked on 14 Oct 2020, 01:59 PM

 When using the GridSearchBox to filter the grid, is it possible to obtain the filtered row items?

I want to know what rows are currently displayed.

4 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 14 Oct 2020, 02:38 PM

Hi Graham,

It is possible and rather straightforward through the OnRead event. I made the following Knowledge Base article that explains the situation: https://docs.telerik.com/blazor-ui/knowledge-base/grid-get-filtered-data.

 

Regards,
Marin Bratanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Graham
Top achievements
Rank 1
Veteran
answered on 15 Oct 2020, 10:15 AM

Thanks. I got it working but had to change my collection to ObservableCollection to get the grid to refresh when I changed the data externally - I am using a drop-down control to apply a filter to the data. (I think Telerik advise using ObservableCollection as the default?).

Question - is there a way of accessing the GridSearchBox text or knowing if the GridSearchBox triggered the OnRead event?

thanks

0
Graham
Top achievements
Rank 1
Veteran
answered on 15 Oct 2020, 10:39 AM

Regarding my last question - I found this which allows me to see the current filters...

https://docs.telerik.com/blazor-ui/components/grid/manual-operations#get-information-from-the-datasourcerequest

thanks

0
Marin Bratanov
Telerik team
answered on 15 Oct 2020, 11:51 AM

Hello Graham,

Indeed, an observable collection is needed when you will be changing the data from an external place via the .Add(), .Remove() and .Clear() methods of the collection, you can read more on this here. We can't recommend that as the default, because whether you need that depends on your scenario and it is up to you to decide. The grid merely needs an IEnumerable - list, array, observable collection.

On getting data from OnRead - that's the way - you can loop over the information in the .Request object to get what you need out of it.

 

Regards,
Marin Bratanov
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Grid
Asked by
Graham
Top achievements
Rank 1
Veteran
Answers by
Marin Bratanov
Telerik team
Graham
Top achievements
Rank 1
Veteran
Share this question
or