2012-10-24 78 views
2

我的環境是:GWTP 0.7,GWT 2.4.0,3.0.1 GXT。這個問題與GXT 3 grid scrolling issue有某種關係,除了那裏的解決方案不適用於我。GXT 3格高度和滾動

我的情況:

public abstract class AbstractGridView extends ViewImpl implements AbstractGridPresenter.MyView { 

    protected final VerticalLayoutContainer cont = new VerticalLayoutContainer(); 

    protected final VerticalLayoutData toolBarData = new VerticalLayoutData(1, -1); 
    protected final VerticalLayoutData contentData = new VerticalLayoutData(1, -1); //grid's layout config 

    protected final ToolBar toolBar = new ToolBar(); 
    protected final TextButton addItemButton = new TextButton(ADDBUTTON_TEXT); 

    @Inject 
    protected AbstractGridView() { 
     toolBar.add(addItemButton); 
     cont.add(toolBar, toolBarData); 
    } 

    public Widget asWidget() { 
     return cont; 
    } 
}  
public class DepartmentsView extends AbstractGridView implements DepartmentsPresenter.MyView { 
    private final Grid<Department> grid; 
    private final ColumnModel<Department> model; 
    private final List<ColumnConfig<Department, ?>> config = new ArrayList<ColumnConfig<Department,?>>(); 
    private final ListStore<Department> store = new ListStore<Department>(PROPS.key()); 
    @Inject 
    public DepartmentsView() { 
     super(); 
     config.add(new ColumnConfig<Department, Long>(PROPS.id())); 
     config.get(config.size() - 1).setHeader(IDCOLUMN_HEADER); 
     config.add(new ColumnConfig<Department, String>(PROPS.name())); 
     config.get(config.size() - 1).setHeader(NAMECOLUMN_HEADER); 
     config.add(new ColumnConfig<Department, String>(companyNameProvider)); 
     config.get(config.size() - 1).setHeader(COMPANYCOLUMN_HEADER); 

     model = new ColumnModel<Department>(config); 

     grid = new Grid<Department>(store, model); 
     grid.getView().setAutoFill(true); 

     filters.initPlugin(grid); 
     filters.setLocal(true); 
     filters.addFilter(idFilter); 
     filters.addFilter(nameFilter); 
     filters.addFilter(companyFilter); 

     cont.add(grid); 
    } 
} 

所有這些被注入BorderLayoutContainer在基本視點:

public class BaseView extends ViewImpl implements BasePresenter.MyView { 
    private final Viewport viewPort = new Viewport(); 

    private final BorderLayoutContainer borderContainer = new BorderLayoutContainer(); 

    private final ContentPanel west = new ContentPanel(); 
    private final ContentPanel north = new ContentPanel(); 
    private final ContentPanel center = new ContentPanel(); 
    private final BorderLayoutData westData = new BorderLayoutData(200); 
    private final BorderLayoutData northData = new BorderLayoutData(); 
    private final BorderLayoutData centerData = new BorderLayoutData(); 
    @Inject 
    public BaseView() { 
     borderContainer.setBorders(true); 
     west.setResize(true); 
     center.setResize(false); 
     center.setHeight("auto"); 
     north.setResize(false); 
     westData.setCollapsible(false); 
     westData.setCollapseMini(false); 
     westData.setMargins(new Margins(5, 5, 5, 5)); 
     northData.setCollapsible(false); 
     northData.setMargins(new Margins(5)); 
     northData.setSize(57); 
     centerData.setCollapsible(false); 
     centerData.setMargins(new Margins(5)); 
     borderContainer.setWestWidget(west, westData); 
     borderContainer.setCenterWidget(center, centerData); 
     borderContainer.setNorthWidget(north, northData); 
     viewPort.add(borderContainer); 
    } 

    public Widget asWidget() { 
     return viewPort; 
    } 

    @Override 
    public void setInSlot(Object slot, Widget content) { 
     setMainContent(content); 
    } 

    private void setMainContent(Widget content) { 
     center.clear(); 
     if (content != null) { 
      center.setWidget(content); 
     } 
    } 
} 

所以,如果加上我的網格VerticalLayoutContainer(續)當我不重視contentData內容也同樣呈現爲VerticalLayoutData(1,-1),即:網格的高度根本不計算,它的內容在頁面底部流動,沒有滾動條可以到達底部頁面邊界以下的任何一行。如果我在問題開始時的鏈接中設置VerticalLayoutData(1,1),我只能看到網格的標題,網格的內容高度計算爲0px(儘管它出現在頁面的DOM中)。只有當我手動設置高度,例如自動調用setHeight(300)網格的高度設置像素和垂直滾動條的那個量顯示去任何行中網格的店,雖然人們可以很容易手動了解設置網格的高度沒有任何理由Viewport託管應用程序窗口的解決方案。

我有什麼遺漏的小部件配置或者這是與它的任何合理的解決方法錯誤?

+0

你似乎缺少例子位 - 'contentData'從來沒有實際使用。如果它用於'Grid',它不能有-1值。 –

+0

我實際上試圖使用id,而不是使用它,並使用contentData instanced作爲VerticalLayoutData(1,1);但是我已經發現了自己的錯誤:它是'center.setResize(false);' – GateKeeper

回答

3

我已經找到了佈局問題:

center.setResize(false); // BaseView's constructor 

這讓BorderLayoutContainer的的ContentPanel不調整子控件(VerticalLayoutContainer),以適應。