如何避免CellList / Table在可视范围发生变化时自动滚动到所选项目 [英] How to avoid CellList/Table from automatically scrolling to selected item when visible range is changed

查看:98
本文介绍了如何避免CellList / Table在可视范围发生变化时自动滚动到所选项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CellList showcase示例( http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList )。但是,在这种情况下,我发现CellList / Table中的一个功能是不可取的:单击某个项目后更改可见范围会导致List / Table自动滚动到所选项目。

您可以尝试上面的展示示例来查看完全相同的行为。当没有选择项目时,无限滚动工作得很好,但是当你点击一个项目然后滚动它时,它会在范围改变时总是跳回到选定项目。



我还发现,只有当焦点仍在项目上时才会发生,也就是说,如果您选择某个项目,然后单击其他位置以失去焦点,则不会发生。

我一直在挖掘GWT代码,并试图找出如何禁用此功能,但没有成功。作为一个简单的解决方法,您可以调用 focus() / code>在某个元素上移除焦点(不删除选择项)。



在展示示例中,在 ShowMorePagerPanel ,添加例如

scrollable.getElement()。focus ();在$ onScroll(ScrollEvent事件)

c>方法。


I was implementing a custom CellTable that has a infinite scroll feature using the CellList showcase example ( http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList ). However, I found a feature in CellList/Table that is undesirable in this case: changing visible range after clicking an item would cause the List/Table to be automatically scrolled to the selected item.

you can try the showcase example in above to see the exact same behavior. When no item is selected, the infinite scroll works just fine, but when you click an item and then scroll it, it will always jump back to the selected item when the range is changed.

I also found that it only happens when the focus is still on the item, that is, if you select an item and then click somewhere else to lose the focus, it wouldn't happen.

I've been digging around the GWT code and trying to find out how to disable this feature with no success. Did anyone handled this situation before?

解决方案

As a simple workaround, you can call focus() on some element, to remove the focus from the item (without removing the selection).

In the showcase example, in ShowMorePagerPanel, add e.g.

scrollable.getElement().focus();

at the beginning of the onScroll(ScrollEvent event) method.

这篇关于如何避免CellList / Table在可视范围发生变化时自动滚动到所选项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆