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

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

2 Answers 712 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 07 Jul 2016, 01:31 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 07 Jul 2016, 02:51 PM

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.
 
0
Paul
Top achievements
Rank 1
answered on 08 Jul 2016, 10:47 AM
Thank you very much that did the trick.
Tags
Data Source
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Paul
Top achievements
Rank 1
Share this question
or