I want to be able to call a function that scrolls the Kendo grid into the selected row. I already tried some methods, but none of them worked,
For example, I tried this:
var grid = $("#Grid").data("kendoGrid"), content = $(".k-grid-content"); content.scrollTop(grid.select());
I also tried this:
var gr = $("#Grid").data("kendoGrid"); var dataItem = gr.dataSource.view()[gr.select().closest("tr").index()]; var material = dataItem.id; var row = grid.tbody.find(">tr:not(.k-grouping-row)").filter(function (i) { return (this.dataset.id == material); }); content.scrollTop(row);
Can someone point me in the right direction, please? :)
--- EDITED ---
For other reasons, I cannot bind to the change event, so I should be able to call a function that scrolls the list to the selected row. This is what I tried with @Antonis answer for me.
var grid = $("#Grid").data("kendoGrid") grid.element.find(".k-grid-content").animate({ scrollTop: this.select().offset().top }, 400);
When I tried this, it scrolled somewhat through the list, but not to the selected line. Am I using a mesh object incorrectly by calling scrollTop on it?
It is too:
var grid = $("#ItemGrid").data("kendoGrid"); grid.scrollToSelectedRow = function () { var selectedRow = this.select(); if (!selectedRow) { return false; } this.element.find(".k-grid-content").animate({ scrollTop: selectedRow.offset().top }, 400); return true; }; grid.scrollToSelectedRow();
jquery asp.net-mvc asp.net-mvc-4 kendo-ui kendo-grid
gardarvalur
source share