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

[Solved] Problem with selecting an element in RadGrid

3 Answers 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter Bogoyavlensky
Top achievements
Rank 1
Peter Bogoyavlensky asked on 17 Apr 2009, 09:45 AM

Situation:

I have multiple-paged Grid control on the page. It showing all positions in cathegory that user selected.

User can search items via search-engine and it shows elements as a list.

When user clicks on element in search-list, I need to refresh Grid and load all elements from cathegory clicked element belongs to.

Also I need to select this element in Grid and there is the problem: I can not find it in Grid.Items collection if this element not on current page.

Do anybody knows how to get all items ( but not only items from currently selected page ) or may be I doing something worng and there is another way should be used?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Apr 2009, 10:21 AM
Hello Peter,

You can refer the following code library submission which actually demonstrates a scenario similar to yours. The project explains on how to highlight a string inside any given cell that holds the reference to the search text. You can alter the logic according to your requirement:
SearchAndHighLightKeyWords

Thanks
Princy.
0
Peter Bogoyavlensky
Top achievements
Rank 1
answered on 20 Apr 2009, 07:53 AM

Hello Princy,

No, this sample did not help me with this problem. MasterTableView still iterate only by rows from current page and ignoring rows from other pages.

I mean if we have RadGrid with 3 pages ( i.e. 15 rows per page gives 1-15, 16-30, 31-45 rows on 1-st, 2nd and 3rd page ) and MainGrid.MasterTableView.Items.Count equals to 15 everytime ( when I expect 45 ).

May be problem is in the way I using this control? I don't use postbacks, all controls on website are ajaxified and usings only callbacks.

protected override void OnPreRender(EventArgs e)  
{  
    base.OnPreRender();  
    MainGrid.Rebind();  
    foreach (GridDataItem item in MainGrid.MasterTableView.Items)  // 15 items here. expected more than 31
    {  
         if (item["cItemID"].Text == eId.ToString())  
         {  
              item.Selected = true;  
              break;  
         }  
    }   

0
Nikolay Rusev
Telerik team
answered on 22 Apr 2009, 06:39 AM
Hello Peter,

RadGrid.MasterTableView.Items will return only GridDataItems on the current page, i.e PageSize will be the same as RadGrid.MasterTableView.Items.Count. This are the items which RadGrid is bound to. It does not persist all items that you supply within it DataSource property, it takes only PageSize items.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Peter Bogoyavlensky
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Peter Bogoyavlensky
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or