out*_*lou 2 user-interface gwt scrollpane
我在ScrollPanel中有一个Celltree.我在UIBinder中设置ScrollPanel的大小如下
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:ScrollPanel ui:field="panel" width="240px" height="1200px"></g:ScrollPanel>
</ui:UiBinder>
Run Code Online (Sandbox Code Playgroud)
在我的Java类中,我有以下内容:
@UiField ScrollPanel panel;
public Arborescence() {
initWidget(uiBinder.createAndBindUi(this));
// Create a model for the tree.
TreeViewModel model = new CustomTreeModel();
/*
* Create the tree using the model. We specify the default value of the
* hidden root node as "Item 1".
*/
CellTree tree = new CellTree(model, "Item 1");
panel.add(tree);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是当我填充CellTree时,水平条没有显示,甚至内容都溢出.垂直条显示正常.
谢谢
更新
使用FireBug,我发现问题来自于 element.style {
overflow: hidden;
}
它似乎是一个覆盖我的CSS的内联CSS.有没有办法改变它?
LIENMAN78的解决方案有点复杂.好吧......经过几个小时的搜索,我找到了一个简单的解决方案:将CellTree包装到HorizontalPanel(或VerticalPanel)中,然后将其添加到ScrollPanel
这是CellTree.ui.XML
<g:ScrollPanel width="100%" height ="1200px">
<g:HorizontalPanel ui:field="panel">
</g:HorizontalPanel>
</g:ScrollPanel>
Run Code Online (Sandbox Code Playgroud)
以及CellTree.java的相关部分
...
@UiField HorizontalPanel panel;
...
panel.add(cellTree)
Run Code Online (Sandbox Code Playgroud)