ScrollPanel(高度)奇怪的行为GWT,

发布于 2024-10-16 06:32:21 字数 1208 浏览 3 评论 0原文

我发现 ScrollPanel 的行为很奇怪。它将高度缩小到大约 30px。 这是我的 ui.xml,

    <g:ScrollPanel styleName="{style.fileViewerWorkspaceBg}">
      <g:FlowPanel>
   <g:FlowPanel>
           <g:FlowPanel>
        <my:OneClickFileUploader ui:field="uploader" enableMultipleFileUpload="true" />
     </g:FlowPanel>
     <g:FlowPanel ui:field="fileTablePanel">
       <cell:SimplePager ui:field="pager"/>
       <cell:CellTable ui:field="fileViewTable"/>
     </g:FlowPanel>  
       <g:Label ui:field="processingField" />
   </g:FlowPanel>
  <g:FlowPanel ui:field="filePreview"/>
  </g:FlowPanel>
</g:ScrollPanel> 

我在 filePreview 和 filePreview 之间切换。 fileTablePanel + uploader,当我显示 uploader+fileTablePanel 时,它显示滚动条,但当我切换到 filePreview 时>,它将 filePreview 面板的高度缩小到 ~30px。可能是什么问题。当我在 firebug 中将 ScrollPanel 的子 div 的高度更改为 100% 时,它会正常显示页面,但似乎我可以无法访问ScrollPanel的子div,有什么解决方法吗?

此外,当尝试将 ScrollPanel 设为 java 类中的 UiField 时,它会抛出异常,它只能有一个子项,而实际上它只有一个子项。

谢谢。 阿尔

I am getting weird behavior of ScrollPanel. It shrinks the height to some how 30px.
Here is my ui.xml

    <g:ScrollPanel styleName="{style.fileViewerWorkspaceBg}">
      <g:FlowPanel>
   <g:FlowPanel>
           <g:FlowPanel>
        <my:OneClickFileUploader ui:field="uploader" enableMultipleFileUpload="true" />
     </g:FlowPanel>
     <g:FlowPanel ui:field="fileTablePanel">
       <cell:SimplePager ui:field="pager"/>
       <cell:CellTable ui:field="fileViewTable"/>
     </g:FlowPanel>  
       <g:Label ui:field="processingField" />
   </g:FlowPanel>
  <g:FlowPanel ui:field="filePreview"/>
  </g:FlowPanel>
</g:ScrollPanel> 

I am toggling between filePreview & fileTablePanel + uploader, When I display uploader+fileTablePanel, it shows me the scroll bars but when i toggle to filePreview, it shrinks the height of filePreview panel to ~30px. What could be the problem. When I change the height of child div of ScrollPanel to 100% in firebug, then it displays the page fine, but it seems that I can not access the child div of ScrollPanel, any workaround?

Moreover when try make the ScrollPanel a UiField in java class it throws the exception that it can have only one child and in actual it has a one child.

thank you.
al

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

转身以后 2024-10-23 06:32:21

我知道这个问题被问到已经有一段时间了,但这是我在遇到同样问题时使用的解决方案:

getContainerElement().getStyle().setHeight(100, Unit.PCT);

这是因为滚动面板是一个简单的面板。

public ScrollPanel() {
this.scrollableElem = getElement();
this.containerElem = Document.get().createDivElement();
scrollableElem.appendChild(containerElem);
initialize();
}

当通过代码或 uibinder 设置/添加小部件时,它将使用 this.containerElem 来保存其子部件,

这是生成的 html。我给它们命名是为了让大家更清楚:

<div id="ScrollPanel" >
    <div id="containerElem" style="position: relative; zoom: 1; height: 100%;">
        <canvas id="myAddedWidget" />
    </div>
</div>

I know it's been a while since this question was asked but this is the solution I used when faced with the same problem:

getContainerElement().getStyle().setHeight(100, Unit.PCT);

This is because Scroll panel is a simple panel.

public ScrollPanel() {
this.scrollableElem = getElement();
this.containerElem = Document.get().createDivElement();
scrollableElem.appendChild(containerElem);
initialize();
}

When a widget is set/added, via code or uibinder, it will used this.containerElem to hold its children

This is the resulting html. I named them in hopes to make it clearer:

<div id="ScrollPanel" >
    <div id="containerElem" style="position: relative; zoom: 1; height: 100%;">
        <canvas id="myAddedWidget" />
    </div>
</div>
赢得她心 2024-10-23 06:32:21

尝试将 styleName 与 height:100%; 设置为 FlowPanel(生成的 HTML 中的 div)。
还有您的代码“缺少结束标记 g:FlowPanel”。
之前的标签可能有拼写错误,应该是 而不是 < /代码>。

<ui:style>
    .container {
      background: #DDD;
      height:1500px; 
      width:100%;
    }
    .fileViewerWorkspaceBg {
        height:100%;
    }
    .zero {
        background-color: yellow;
        height:300px;
    }
    .first {
        background-color: blue;
        height:50px;
    }
    .fileTablePanel {
        background-color: red;
        height:150px;
    }
</ui:style>

<g:ScrollPanel styleName="{style.fileViewerWorkspaceBg}">
    <g:FlowPanel styleName="{style.container}">
        <g:FlowPanel styleName="{style.zero}">
            <g:FlowPanel styleName="{style.first}">
                <g:Label>OneClickFileUploaderPanel</g:Label>
                <my:OneClickFileUploader ui:field="uploader" 
                  enableMultipleFileUpload="true" /> 
            </g:FlowPanel>
            <g:FlowPanel styleName="{style.fileTablePanel}">
                <g:Label>fileTablePanel</g:Label>
                <cell:SimplePager ui:field="pager" /> 
                <cell:CellTable ui:field="fileViewTable" /> 
            </g:FlowPanel>
            <g:Label>Label</g:Label>
        </g:FlowPanel>
   </g:FlowPanel>
</g:ScrollPanel>

Try to set styleName with height:100%; to FlowPanel (div in resulting HTML).
Also your code "missing end tag g:FlowPanel".
Probably typo in tag before </g:ScrollPanel>, should be </g:FlowPanel> instead of <g:FlowPanel />.

<ui:style>
    .container {
      background: #DDD;
      height:1500px; 
      width:100%;
    }
    .fileViewerWorkspaceBg {
        height:100%;
    }
    .zero {
        background-color: yellow;
        height:300px;
    }
    .first {
        background-color: blue;
        height:50px;
    }
    .fileTablePanel {
        background-color: red;
        height:150px;
    }
</ui:style>

<g:ScrollPanel styleName="{style.fileViewerWorkspaceBg}">
    <g:FlowPanel styleName="{style.container}">
        <g:FlowPanel styleName="{style.zero}">
            <g:FlowPanel styleName="{style.first}">
                <g:Label>OneClickFileUploaderPanel</g:Label>
                <my:OneClickFileUploader ui:field="uploader" 
                  enableMultipleFileUpload="true" /> 
            </g:FlowPanel>
            <g:FlowPanel styleName="{style.fileTablePanel}">
                <g:Label>fileTablePanel</g:Label>
                <cell:SimplePager ui:field="pager" /> 
                <cell:CellTable ui:field="fileViewTable" /> 
            </g:FlowPanel>
            <g:Label>Label</g:Label>
        </g:FlowPanel>
   </g:FlowPanel>
</g:ScrollPanel>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文