GWT DataGrid 不显示,CellTable 显示
GWT DataGrid does not display, CellTable does
概述
我有一个应用程序,它包含一个 SplitLayoutPanel,它有一个 StackLayoutPanel,左侧有两个菜单选项,右侧有一个 DeckLayoutPanel。 DeckLayoutPanel 有两个子面板,一个是包含 Label 的 SimpleLayoutPanel,一个是包含 Label 的 DockLayoutPanel,另一个是 SimpleLayoutPanel。最后一个 SimpleLayoutPanel 包含一个 DataGrid。
SplitLayoutPanel (TestUI)
|
+ StackLayoutPanel
| |
| + CellList (Profile)
| |
| + CellList (Admin)
|
+ DeckLayoutPanel
|
+ SimpleLayoutPanel
| |
| + Label
|
+ DockLayoutPanel (BudgetPanel)
|
+ Label
|
+ SimpleLayoutPanel (LedgerPanel)
|
+ DataGrid
所有子面板的高度和宽度均由其包含面板设置为 100%。
预期行为
预期的行为是单击 StackLayoutPanel 中的 "Budget" 菜单项将显示 BudgetPanel,包括 LedgerPanel 的 DataGrid。
观察到的行为
单击"Budget"菜单项时,将显示DockLayoutPanel及其header标签,显示DataGrid列header,但不显示DataGrid行.
当 Label 添加到 DockLayoutPanel 的南部区域时,应用程序编译但不显示任何内容,甚至不显示顶级 StackLayoutPanel。
当 DataGrid 替换为 CellTable 时,会显示数据(尽管每行的高度远远超出了容纳数据所需的高度)。
问题
需要做什么才能使 DataGrid 按预期显示?
如何设置行的样式以使其具有更小的高度?
源代码
演示此问题的完整源代码可在 GitHub.
上找到
我非常快速地查看了您的代码,据我所见,您为数据网格设置了 100% 的高度。不幸的是,在 GWT 中,您必须为数据网格设置一个固定值。
datagrid.setHeight("300px");
您可以通过动态更改数据网格的高度来解决此问题。
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
datagrid.setHeight(Window.getClientHeight() - menuSize);
}
});
我从 GWT 邮件列表上的 Thomas Broyer 那里得到了答案。诀窍是在 BudgetPanel 实例显示在其包含的 DeckLayoutPanel 中时调用 forceLayout()。
感谢所有建议。
概述
我有一个应用程序,它包含一个 SplitLayoutPanel,它有一个 StackLayoutPanel,左侧有两个菜单选项,右侧有一个 DeckLayoutPanel。 DeckLayoutPanel 有两个子面板,一个是包含 Label 的 SimpleLayoutPanel,一个是包含 Label 的 DockLayoutPanel,另一个是 SimpleLayoutPanel。最后一个 SimpleLayoutPanel 包含一个 DataGrid。
SplitLayoutPanel (TestUI)
|
+ StackLayoutPanel
| |
| + CellList (Profile)
| |
| + CellList (Admin)
|
+ DeckLayoutPanel
|
+ SimpleLayoutPanel
| |
| + Label
|
+ DockLayoutPanel (BudgetPanel)
|
+ Label
|
+ SimpleLayoutPanel (LedgerPanel)
|
+ DataGrid
所有子面板的高度和宽度均由其包含面板设置为 100%。
预期行为
预期的行为是单击 StackLayoutPanel 中的 "Budget" 菜单项将显示 BudgetPanel,包括 LedgerPanel 的 DataGrid。
观察到的行为
单击"Budget"菜单项时,将显示DockLayoutPanel及其header标签,显示DataGrid列header,但不显示DataGrid行.
当 Label 添加到 DockLayoutPanel 的南部区域时,应用程序编译但不显示任何内容,甚至不显示顶级 StackLayoutPanel。
当 DataGrid 替换为 CellTable 时,会显示数据(尽管每行的高度远远超出了容纳数据所需的高度)。
问题
需要做什么才能使 DataGrid 按预期显示?
如何设置行的样式以使其具有更小的高度?
源代码
演示此问题的完整源代码可在 GitHub.
上找到我非常快速地查看了您的代码,据我所见,您为数据网格设置了 100% 的高度。不幸的是,在 GWT 中,您必须为数据网格设置一个固定值。
datagrid.setHeight("300px");
您可以通过动态更改数据网格的高度来解决此问题。
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
datagrid.setHeight(Window.getClientHeight() - menuSize);
}
});
我从 GWT 邮件列表上的 Thomas Broyer 那里得到了答案。诀窍是在 BudgetPanel 实例显示在其包含的 DeckLayoutPanel 中时调用 forceLayout()。
感谢所有建议。