GXT 3 - 排序导致网格水平滚动

时间:2014-09-24 11:29:54

标签: gwt gxt

如果我尝试排序一个不在视野中的列(我需要向右滚动才能看到它) 然后列排序但表格向左滚动,(我排序的列再次不在视图中)

可以在GXT展示的Basic Gid中尝试: 只需将列的宽度设置得更大,以便水平滚动条显示出来,然后尝试在表格的末尾滚动并进行排序。

如何解决这个问题?

由于

3 个答案:

答案 0 :(得分:2)

这是我解决它的方式: 在排序之前覆盖onDataChanged的{​​{1}}并将GridView设置为true,然后将其设置回原来的状态。我想知道为什么这不是默认行为。

preventScrollToTopOnRefresh

答案 1 :(得分:1)

没有内置功能可以防止这种行为,因此您必须自己编写。您只需要在排序之前存储滚动状态并在以下之后恢复它:

// save scroll state
final int scrollTop = getView().getScroller().getScrollTop();
final int scrollLeft = getView().getScroller().getScrollLeft();

// restore scroll state
getView().getScroller().setScrollTop(scrollTop);
getView().getScroller().setScrollLeft(scrollLeft);

答案 2 :(得分:0)

@Darek Kay:非常感谢你。通过从EditorTreeGrid中选择值来更改选项时,我遇到了向下滚动的问题。你的建议对我有用。这就是我为我所做的工作:

    final int scrollTop = editorTreeGrid.getView().getScroller().getScrollTop();
    final int scrollLeft = ditorTreeGrid.getView().getScroller().getScrollLeft();

    editorTreeGrid.getView().refresh(true);

    editorTreeGrid.getView().getScroller().setScrollTop(scrollTop);
    editorTreeGrid.getView().getScroller().setScrollLeft(scrollLeft);