找回密码
 立即注册

QQ登录

只需一步,快速开始

JAYDEN

注册会员

13

主题

25

帖子

104

积分

注册会员

积分
104
JAYDEN
注册会员   /  发表于:2023-3-24 17:33  /   查看:1345  /  回复:3
10金币
grid.scrollIntoView能否默认将滚动的行置顶视口区域的顶部? 还有就是如果跳转的行在当前是视口区域内 貌似就不会滚动了。

附件: 您需要 登录 才可以下载或查看,没有帐号?立即注册

最佳答案

查看完整内容

请参考这个示例, 其中有移动到顶部的代码 https://www.grapecity.com/wijmo/demos/Grid/PagingScrolling/ScrollingandViewRange#demo_source_name

3 个回复

倒序浏览
最佳答案
最佳答案
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2023-3-24 17:33:09
来自 4#
请参考这个示例, 其中有移动到顶部的代码
https://www.grapecity.com/wijmo/ ... ge#demo_source_name

  1.     // set top cell
  2.     document.getElementById('scrollToTop').addEventListener('click', function () {
  3.         if (true) {
  4.             //
  5.             // get cell rect, adjust scrollPosition.y to bring it to the top
  6.             var rc = theGrid.cells.getCellBoundingRect(100, 0, true);
  7.             theGrid.scrollPosition = new wjCore.Point(theGrid.scrollPosition.x, -rc.top);
  8.             //
  9.         }
  10.         else {
  11.             //
  12.             // simpler but less efficient (requires a timeOut)
  13.             theGrid.scrollIntoView(theGrid.rows.length - 1, -1);
  14.             setTimeout(function () {
  15.                 theGrid.scrollIntoView(100, -1);
  16.             });
  17.         }
  18.     });
复制代码
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2023-3-24 18:06:13
2#
我没有理解你具体的需求,只能猜测你是不是要置顶某些行,这个目前没有办法做到
回复 使用道具 举报
JAYDEN
注册会员   /  发表于:2023-3-24 18:23:16
3#
Richard.Ma 发表于 2023-3-24 18:06
我没有理解你具体的需求,只能猜测你是不是要置顶某些行,这个目前没有办法做到

不是置顶,就是跳转到某行的时候希望它刚好滚到视口区域的第一行,而不是最后一行或中间。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部