I would like to get the global index of a given Grid row in order to implement a multi-selection across a grid with virtual scrolling enable. It's easy to get the index within the displayed rows:
At this point, to logic would be to use the page number / page size to determine what is the global index of the selected row.
However, this ain't working with the Kendo grid (except for the first page) as the grid is displaying rows from page previously loaded.
Example: You have records from 1 to 200 with a page size of 100. When you'll scroll down to the record #100, the dataBound grid event will be triggered and you'll be able to notice the dataSource page has changed from 1 to 2.
You'll also notice some rows from page 1 are still visible and their index will be calculated as a page 2 element.
For instance, the record #96 has the index 95 as long as the grid remain on page 1. When you'll switch to page 2, the record #96 will be displayed (as the first item). At this point, index returned by the grid for that row will be 0. If you apply the page number / size rule above, you'll end up with the index 100.
Is there any solution that doesn't involve a row index calculated on the server side?
Note If we had a PK column, it could be possible to use it to build a list of index, but we don't always have a PK column so this isn't an option.
var kendoGrid = $("#myGrid").data("kendoGrid");
var index = kendoGrid.items().index(kendoGrid.select());At this point, to logic would be to use the page number / page size to determine what is the global index of the selected row.
//Pages are base 1index += (kendoGrid.dataSource.page() - 1) * kendoGrid.dataSource.pageSize();However, this ain't working with the Kendo grid (except for the first page) as the grid is displaying rows from page previously loaded.
Example: You have records from 1 to 200 with a page size of 100. When you'll scroll down to the record #100, the dataBound grid event will be triggered and you'll be able to notice the dataSource page has changed from 1 to 2.
You'll also notice some rows from page 1 are still visible and their index will be calculated as a page 2 element.
For instance, the record #96 has the index 95 as long as the grid remain on page 1. When you'll switch to page 2, the record #96 will be displayed (as the first item). At this point, index returned by the grid for that row will be 0. If you apply the page number / size rule above, you'll end up with the index 100.
Is there any solution that doesn't involve a row index calculated on the server side?
Note If we had a PK column, it could be possible to use it to build a list of index, but we don't always have a PK column so this isn't an option.