how can I get Index Of selectedRow kendo UI

Kar Inter picture Kar Inter · Nov 2, 2015 · Viewed 10.9k times · Source

I use belowe code to get selected code but I need get current Row Index to move up abd down , How can I get row index of selecetd Item : my code :

 $("#btnup").click(function () {

        var grid = $("#grid").data("kendoGrid");
        var selectedItem = grid.dataItem(grid.select());

        if (selectedItem != undefined) {
            alert("The Row Is SELECTED");
            // here need row index
        }
        else
            alert("NO Row Is SELECTED")
    });

Answer

Jayesh Goyani picture Jayesh Goyani · Nov 2, 2015

Please try with the below code snippet.

$("#btnup").click(function () { 
    var grid = $("#grid").data("kendoGrid");
    var selectedItem = grid.dataItem(grid.select()); 
    if (selectedItem != undefined) {
        // I have added selected row index on below code line
        alert("The Row Is SELECTED at index: " + grid.select().index()); 
    }
    else
        alert("NO Row Is SELECTED")
});

Let me know if any concern.