11

I'm trying to convert a cellTable into adatagrid, because I want to add a search handler later and therefor I need fixed column headers. At the moment I extend the celltable/datagrid class and put the widget into a simplelayoutpanel and add this to my tabpanel.

If I use the celltable, all works fine and the data shows up. If I change the type of the class to datagrid, the data shows sometimes up (The column names are always there). To add something to the table I used setRowData or a dataProvider. If I set breakpoints to delay the loading of the table content, the table does sometimes contain data. If I later call the redraw method for the table, the table shows the correct information. But the table should load automatically the content. At other "positions" of my project I used the datagrid also and it worked in Dialogboxes.

I think there must be a bug with the drawing of the items, because if I call .getRowCount on the table or the deprecated .getDisplayedItems, it returns me the correct number of items which should be in the table. Also if I add a selection model to the table and select a item, the item contains valid data.

4

3 回答 3

8

DataGrid 需要放在实现 ProvidesResize 接口的 LayoutPanel 或 Panel 中才可见。ScrollPanel 实现了该接口。

此外,从 DataGrid 到根元素/面板的这一系列 LayoutPanel 必须不间断。在您的面板层次结构中似乎就是这种情况。

最后,您必须使用 RootLayoutPanel 而不是 RootPanel 来添加您的 LayoutPanel。那么您是否确保将您的 SimpleLayoutPanel 添加到 RootLayoutPanel ?

另请参阅此 GWT:DataGrid - 设置高度 100% 未正确呈现

于 2012-08-30T05:15:50.973 回答
8

这是我的 2 美分。

当在正确形成的“LayoutPanel 或实现 ProvidesResize”树结构的面板之外渲染 DataGrid 时,我发现我始终需要牢记以下几点:

  1. 正如这个问题所解释的,高度 DataGrid 属性需要一个明确的值,例如“123px”。没有这个,DataGrid 不会显示它的数据行(即使它们在 DOM 中)。

  2. 如果将 DataGrid 放在未聚焦的DecoratedTabPanel 选项卡中,则需要在此类选项卡获得焦点时调用 DataGrid.redraw() 。同样,没有这个,DataGrid 不会显示它的数据行(即使它们在 DOM 中)。

我希望这有帮助。

于 2013-02-21T20:44:52.237 回答
3

就我而言,这是由以下原因引起的: DataGrid rows not visible in second tab of TabLayoutPanel

于 2013-11-27T08:38:03.770 回答