GXT网格布局问题 - 无垂直滚动条

时间:2013-02-21 13:11:28

标签: extjs grid scrollbar gxt

我正在尝试将Grid添加到固定大小(250像素)的VerticalLayoutContainer中,并让用户能够垂直滚动。

我正在使用以下代码,但网格根本不显示。

    VerticalLayoutContainer vPanel = new VerticalLayoutContainer();
    vPanel.setHeight("250px");
    vPanel.add(grid, new VerticalLayoutData(1, 1));

    grid.setHeight("auto");

    add(vPanel);

网格在其他情况下显示,但会覆盖其他GUI元素(无滚动条)。

希望对于那些对Sencha GXT更有经验的人来说,这是一个简单的解决方案。

感谢任何人抽出时间帮助我...

2 个答案:

答案 0 :(得分:2)

试试这个:

vPanel.getScrollSupport().setScrollMode(ScrollMode.auto);

如果它不起作用,那么试试这个:

`

ContentPanel p = new ContentPanel();
p.setHeaderVisable(false);
p.setBodyBorder(false);
p.setBorder(false);
p.setHeigh(250);
vPanel.add(p);
p.add(grid);

`

然后网格,将自动具有滚动模式。

答案 1 :(得分:1)

我在Grid中遇到ContentPanel同样的问题,也就是说,网格没有显示垂直滚动条。在将网格添加到面板后,我立即使用ContentPanel#forceLayout,它解决了问题。这是实际的代码:

Grid<Pet> grid = new Grid<>(listStore, columnModel);
grid.setBorders(true);
grid.setColumnReordering(true);
grid.setLoadMask(true);
grid.setSelectionModel(selectionModel);
grid.setView(createGridView());
ContentPanel contentPanel = new ContentPanel();
contentPanel.setHeaderVisible(false);
contentPanel.add(grid);
contentPanel.forceLayout(); // <---- this is the line that fixed the problem!
相关问题