I want to get index of selected row in kendo grid. The code below returns index of a row based on current page. It does not obey the grid's page number and page size.
So if grid's page size is 50, you are on 2nd page and you click on 5th row then index should be 54
because you clicked on 55th row.
Both the options below does not work
Option 1
grid.on('click', '.t-doc', function (e) {
var kendoGrid = $("#grid").getKendoGrid();
var row = $(e.target).closest("tr");
var index = $("tr", kendoGrid.tbody).index(row);
}
Option 2
grid.on('click', '.t-doc', function (e) {
var kendoGrid = $("#grid").getKendoGrid();
var ds = kendoGrid.dataSource;
var dataItem = kendoGrid.dataItem($(e.target).closest("tr"));
var index = ds.indexOf(dataItem);
var selectedItem = grid.dataItem(grid.select());
– Steve Greene