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

Preselect 1 row in radgrid with paging

2 Answers 175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 29 Mar 2016, 10:54 AM

Hi,

I need to select 1 row in a radgrid ( a parameter is passed in url like myPage.aspx?ID=93 )

If the row to select is in the first page displayed of the radgrid, this is OK.

However, if the row to select is, for example, in the page 5, this don't work

I do so in PreRender:

        protected void Grid_Version_PreRender(object sender, EventArgs e)
        {
            if (!IsPostBack && SelectedRecetteVersion != null)
            {
                foreach (GridDataItem item in Grid_ArticleRecette.MasterTableView.Items)
                {
                    if (item.GetDataKeyValue("RecetteID").ToString() == myID)
                    {
                        item.Selected = true;
                    }
                }
            }

 

I need to display to good page with the row selected

 

Thanks for your help please

 

 

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 30 Mar 2016, 11:38 AM
Hello Pierre,

If the item that needs to be pre-selected is not on the current page, it will not be present in the Items collection of the grid. In order to find the item in such scenario you will have to follow those steps:
  • Temporarily disable the paging functionality and rebind the grid;
  • Traverse all items until you find the searched id;
  • Calculate the PageIndex where that item will be displayed if the paging was enabled;
  • Enable the paging, change the page index and rebind;
  • Select the item.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Pierre
Top achievements
Rank 1
answered on 30 Mar 2016, 02:43 PM
Thank you Konstantin,

 

So It's OK for me !

Thanks a lot

 

 

 

Tags
Grid
Asked by
Pierre
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Pierre
Top achievements
Rank 1
Share this question
or