[英]Horizontal scrollPanel not displaying with CellTree
我在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>
在我的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);
}
我的問題是,當我填充CellTree時,即使內容溢出,也不顯示水平欄。 垂直欄顯示正常。
謝謝
更新
使用FireBug,我發現問題出在element.style { overflow: hidden; }
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>
和CellTree.java的相關部分
...
@UiField HorizontalPanel panel;
...
panel.add(cellTree)
這不是最漂亮的解決方案,但這是一個快速解決方案。
/* fix horizontal scroll issue */
.cellTreeWidget>div,
.cellTreeWidget>div>div>div>div>div,
.cellTreeWidget>div>div>div>div>div>div>div>div>div
{
overflow: visible !important;
}
如果要覆蓋CellTree.Style,則可以保持.cellTreeWidget不變,但是如果您想快速又臟地將其更改為您添加到CellTree的任何樣式名稱,則可以將其保留為原樣。
您只能執行一次,並在模塊xml中進行替換,以便當CellTree在內部調用GWT.create(Resource.class)時,它會自動替換為帶有您的修訂的版本。
<replace-with class="com.foo.common.client.gwt.laf.resource.CellTreeResources">
<when-type-is class="com.google.gwt.user.cellview.client.CellTree.Resources" />
</replace-with>
public class CellTreeResources implements CellTree.Resources
{
@Override
public ImageResource cellTreeClosedItem()
{
return CellBrowserResourcesImpl.INSTANCE.cellTreeClosedItem();
}
@Override
public ImageResource cellTreeLoading()
{
return LoadingResource.INSTANCE.loadingBar();
}
@Override
public ImageResource cellTreeOpenItem()
{
return CellBrowserResourcesImpl.INSTANCE.cellTreeOpenItem();
}
@Override
public ImageResource cellTreeSelectedBackground()
{
return CellBrowserResourcesImpl.INSTANCE.cellTreeSelectedBackground();
}
@Override
public Style cellTreeStyle()
{
return CellBrowserResourcesImpl.INSTANCE.cellTreeStyle();
}
public interface CellBrowserResourcesImpl extends CellTree.Resources
{
static final CellBrowserResourcesImpl INSTANCE = GWT.create(CellBrowserResourcesImpl.class);
@Override
@Source({ CellTree.Style.DEFAULT_CSS, "cellTree.css" })
Style cellTreeStyle();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.