slickgrid - autoscroll the viewport when selecting data

不问归期 提交于 2019-12-11 11:28:51

问题


I am using slickgrid for ability to enter data like excel style.

User will enter data. Then after selecting required data graph will generate.

Problem is , When selecting data with mouse, spreadsheet will not let you scroll with the mouse past AG cells or below the number 10 cell. Which means if there is large amount of data then selection will not remain user friendly.

I want auto scroll of spreadsheet when user want to select data beyond AG column and row10.

I want something like this


回答1:


Add this CSS to your page

.slick-viewport { overflow-x: auto !important; overflow-y: auto !important; }




回答2:


I have figured out this issue by finding mouse pointer position and applied scrolling at the positions where i wanted automatic scroll ...

$('#myGrid').mousemove(function(e){
      var parentOffset = $(this).offset(); 
      diffX = ( ( parentOffset.left + $('#myGrid').width() ) - e.pageX);
      diffY = ( ( parentOffset.top + $('#myGrid').width() ) - e.pageY);
      if (diffX < 59 && diffX > 17){
          $('.slick-viewport ').scrollLeft($('.slick-viewport ').scrollLeft() + 5);
      }

      if (diffY < 389 && diffY > 366){
          $('.slick-viewport ').scrollTop($('.slick-viewport').scrollTop() + 5);
      }

    });


来源:https://stackoverflow.com/questions/21107466/slickgrid-autoscroll-the-viewport-when-selecting-data

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