如何防止 extjs 网格在点击单元格时滚动?
我目前正在使用基于可编辑网格示例的 Extjs 4 网格组件。我希望有一个与每个单元格关联的链接,这样当我单击一个单元格时,它会将我带到另一个页面。但是,当单击链接时页面上会触发垂直滚动。
例如尝试减小 http://dev 的大小.sencha.com/deploy/ext-4.0.0/examples/grid/cell-editing.html,第一次点击网格会滚动页面,使网格位于中心,事件被吞掉。您必须再次单击才能注册 cellclick 事件。这只发生在 IE 中(我使用的是版本 8)。好消息是,其他浏览器不会发生这种情况,这可能是一个错误,有没有办法阻止第一次滚动操作的发生?
谢谢
I am currently using the grid component with Extjs 4 based on the editable grid example. I would like to have a link associated with each cell so that when I click on a cell it takes me to another page. However, when there is a vertical scroll that is trigered on the page when clicking on the link.
e.g. try reducing the size of http://dev.sencha.com/deploy/ext-4.0.0/examples/grid/cell-editing.html, the first click on the grid scrolls the page so that the grid is on the center and the event is swallowed. You have to click again to have the cellclick event registered. This only happens in IE (I am using version 8). The good news is that this does not happen with other browsers, could this be a bug and is there a way to prevent this first scrolling action from happening?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了同样的问题,并在 Sencha 讨论板上找到了解决方案。
添加此代码确实对我有用:
更多信息:
http://www.sencha.com/forum/showthread.php?133983-How-to-prevent-extjs-grid-from-scrolling-when-clicking-on-a-cell
I´ve had the same problem and found a solution on the Sencha discussion board.
Adding this code did work for me:
More information:
http://www.sencha.com/forum/showthread.php?133983-How-to-prevent-extjs-grid-from-scrolling-when-clicking-on-a-cell
试试这个补丁
Try out this patch
我今天在 ExtJS 4.2 中遇到了同样的问题,早期的解决方案对我不起作用,在 gridpanel 上使用此配置可以完全解决问题:
例如:
I had this same problem with ExtJS 4.2 today and the earlier solutions were not working for me, using this config on the gridpanel handled the problem fully:
For example:
这可能类似于此问题: 在 IE7 中,第一次单击网格会导致 ExtJS Ext.grid.GridPanel 跳转到页面顶部
尝试在网格周围的容器上使用position:relative;zoom:1来给它hasLayout
this could be similar to this problem: In IE7 the first click on a grid causes an ExtJS Ext.grid.GridPanel to jump to the top of the page
try position:relative;zoom:1 on the container around the grid to give it hasLayout