问题
I have a kendoGrid with virtual scrolling. Now i am trying to go to a certain position on the grid. I was able to get the top position by using:
//Get the virtualScrollable
var vs = mainGrid.wrapper.find('.k-grid-content').data('kendoVirtualScrollable');
var scrollTop = vs.verticalScrollbar.scrollTop();
//go to the position
$("#mainGrid div.k-virtual-scrollable-wrap").animate({scrollTop: scrollTop}, 0);
$("#mainGrid div.k-scrollbar-vertical").animate({scrollTop: scrollTop}, 0);
which works perfectly for getting me to auto scroll down.
now i want to scroll to the right...
NOPE!
i cant find scrollLeft()! For some reason kendoVirtualScrollable only has verticalScrollbar and not horizontalScrollbar.
Also, when i use developer tools to try and click on the horizontal scroll bar it keeps pointing to .k-virtual-scrollable-wrap which has a scrollLeft() = 0.
Anyone out there know how to get the scrollLeft() of kendoVirtualScrollable??
回答1:
This works for me:
https://dojo.telerik.com/abEYO/4
$('.k-virtual-scrollable-wrap').animate({
scrollLeft: 300
}, 1000);
setTimeout(function () {
alert($('.k-virtual-scrollable-wrap').scrollLeft());
}, 5000);
来源:https://stackoverflow.com/questions/46937801/how-to-get-scrollleft-from-kendovirtualscrollable