1

我在 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; }

似乎它是覆盖我的 CSS 的内联 CSS。有没有办法改变它?

4

2 回答 2

5

LIENMAN78 的解决方案有点复杂。嗯...经过几个小时的搜索,我找到了一个简单的解决方案:将 CellTree 包装到 Horizo​​ntalPanel(或 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)
于 2011-10-26T14:08:12.950 回答
1

这不是最漂亮的解决方案,但这是一个快速修复。

/* 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();
    }
}
于 2011-10-26T03:02:20.807 回答