How to get scrollLeft() from kendoVirtualScrollable

笑着哭i 提交于 2020-01-06 06:06:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!