2013-02-21 86 views
1

我試圖將網格添加到固定大小(250像素)的VerticalLayoutContainer,並讓用戶能夠垂直滾動。GXT網格佈局問題 - 無垂直滾動條

我用下面的代碼,但是,電網不顯示在所有。

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

    grid.setHeight("auto"); 

    add(vPanel); 

該網格在其他情況下顯示,但會覆蓋其他GUI元素(無滾動條)。

但願這是爲那些更有經驗與煎茶GXT一個簡單的辦法。

由於任何人抽出時間來幫我...

+0

什麼類型的組件添加到vPanel(即add(vPanel)方法)?一個ContentPanel? – 2013-02-21 13:49:30

+0

這是一個流程佈局容器... – Eugen 2013-02-21 15:01:58

+0

好幾個問題 - 1.您使用的是什麼版本的GXT? 2.所提供的代碼示例是否完全無法工作(即沒有顯示網格),還是顯示了代碼示例但涵蓋了其他GUI元素? 3.你還想渲染頁面上是否有其他元素? – 2013-02-21 21:05:13

回答

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

我在ContentPanel中的Grid有同樣的問題,也就是說,網格沒有顯示垂直滾動條。在將面板添加到面板後,我立即使用了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!