Search code examples
kendo-uikendo-grid

Highlight a specific row of Kendo grid


I've a Kendo grid with 100 records (10 records per page). Now I want to select 25th row (or else nth row) by default when ever I open a page.

How can I achieve this?


Solution

  • Use grid.select() from the grid's dataBound event:

    dataBound: function (e) {
        var rowNumber = 3; // select the third row
        this.select("tr:eq(" + rowNumber + ")");
        console.log(this.dataSource.page());
    }
    

    See this example.

    If you only want to select a specific row from the data set if is currently displayed, you can use this.dataSource.page() to determine which page you're on and whether the row you want to select is on it. Similarly, if you want to automatically jump to the page the row is on, you can use the pageSize value of the data source to calculate the page you need to select, and set it with dataSource.page(calculatedPageNumber).