I have a listview that a user can click a button on and go to a new page. I pass the current page and the id of the selected item to the new page. When the user clicks on a link to return to the page with the listview, the page and the id are passed back. I can change the page to the correct page and select the record in the dataBound event as shown below but, I have not been able to figure out how to scroll it into view. Is there a way to do that?
function dataBound(e){
var listViewDS = $("#lvDisplay").data("kendoListView").dataSource;
var myPage = '@ViewBag.CurrentPage';
var myId = '@ViewBag.CurrentId';
if (myPage != 1){
setTimeout(() => { listViewDS.page(myPage); }, 1000);
var listView = $("#lvDisplay").data("kendoListView");
var dataItems = listView.dataSource.view();
var index = 0;
for (var j = 0; j < dataItems.length; j++) {
if (dataItems[j].Id == myId) {
index = j;
listView.select(index);
var row = e.sender.element.find("[data-uid='" + dataItems[j].uid + "']");
row.addClass("k-state-selected");
};
};
}
}
I have tried the code below but always get an error for top.
$("#lvDisplay").scrollTop($("#lvDisplay").find(".k-state-selected").position().top);