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

[Solved] Searching for RadGrid Data

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 23 Jul 2010, 04:58 PM
Hello all...

Does any know of a way to search for a row in a multi-paged grid, and move to that page/record in the grid?  I'm not talking about filtering the grid down to the record being searched for.

My users have a need where they are looking for a record, but not necessarily filter for that record.  They may simply want to start working from the record they are searching for and continue forward or backward depending on their needs.

My problem is, I can't seem to find a way, either through datasource, or the grid, to do this.  I can "guess" fairly accurately based on the # of records and the sort, but only if the table remains static.  These rows of data will change frequently, so that idea went out the window quick.

Anybody have any ideas?

Thanks, Greg

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 29 Jul 2010, 07:21 AM
Hello Greg,

Since RadGrid is bound only to the Items in the currently displayed page, this scenario is not a straightforward one. The general idea is to search in the underlying data-source, located the item, calculate on which page it should be positioned and page the grid to the page in question. However, this approach will be further complicated if (as you have correctly noted) have sorting and, even worse, filter expressions. In that case, you will have to take those, parse them, apply them to the underlying data and go from there with the above solution. Taking all this into account, I'd suggest that when you need to search for an item you take the following steps:

1. Switch off the paging for the grid: RadGrid1.MasterTableView.AllowPaging = false;

2. Immediately after that rebind the grid - RadGrid1.Rebind().

3. Now you should have all the items in the grid itself. Search for the item required by its data key value or any other condition pertinent to your scenario. Locate the item, take its ItemIndex and calculated the page on which it should be located.

4. Switch paging back on.

5. Set the current page index of the MasterTableView to the page asceratained above.

6. Rebind the grid again.

Hope this information will prove helpful.

Greetings,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
George
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or