Selecting a row which is on a different page of the grid

3 posts, 1 answers
  1. Paul
    Paul avatar
    24 posts
    Member since:
    May 2016

    Posted 07 Jul Link to this post

    Hi I have a grid with 3 pages with 20 records on each.

    I am trying to select and go to a certain record on a different page.

    The issue is I don't know how to do this its easy to do within the page your on using 

    var grid = $("#ListUserGrid").data("kendoGrid");

    grid.select(2);

    so i thought it would be as easy as 

    var grid = $("#ListUserGrid").data("kendoGrid").datasource.data();
    grid.select(2);

    and obviously that doesn't work 

    this is what i have at the moment 

     var grid2 = $("#ListUserGrid").data("kendoGrid").dataSource.data();

     if (useridValue > 0)
                {
                    for (var i = 0; i < grid2.length; i++)
                    {
                        var t = grid2[i]["UserId"];
                        arraygrid.push({ "idx": i, "UserId": t });
                        if (arraygrid[i]["UserId"] == useridValue)
                        {                        
                            //var items = grid2.items();
                            var idx = arraygrid[i]["idx"];                       
                            var loc = grid2[idx]; 
                        }                   
                    }
                    itemsToSelect.push(loc);
                    grid2.select(itemsToSelect);
                    useridValue = 0;
                    return;
                }

     

    Any help would be appreciated.

     

  2. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 07 Jul Link to this post

    Hello Paul,

    What the Grid selection is doing under the hood is to add the k-state-selected CSS class to the item i.e. only visually indicates the item as selected. This is why selecting items on other pages is not directly supported. If you would like to manually go to another page of the Grid, you could use the page method of the Grid's dataSource.
    E.g.

    grid.dataSource.page(2);

    After the Grid is on the specific page (i.e. the dataBound event is triggered) you could use the select method of the Grid to select the appropriate item.

     

    Regards,
    Dimiter Madjarov
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
  4. Paul
    Paul avatar
    24 posts
    Member since:
    May 2016

    Posted 08 Jul in reply to Dimiter Madjarov Link to this post

    Thank you very much that did the trick.
Back to Top