Preselect 1 row in radgrid with paging

3 posts, 0 answers
  1. Pierre
    Pierre avatar
    11 posts
    Member since:
    Mar 2016

    Posted 29 Mar Link to this post

    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. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 30 Mar Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pierre
    Pierre avatar
    11 posts
    Member since:
    Mar 2016

    Posted 30 Mar Link to this post

    Thank you Konstantin,

     

    So It's OK for me !

    Thanks a lot

     

     

     

Back to Top