问题描述
我正在尝试将 cellTable
转换为 datagrid
,因为我想稍后添加一个搜索处理程序因此我需要固定的列标题。目前,我扩展了 celltable
/ datagrid
类,并将小部件放入 simplelayoutpanel
并将其添加到我的 tabpanel
中。
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
.
如果我使用 celltable
,一切正常,数据显示。如果我将类的类型更改为 datagrid
,则数据有时会显示(列名始终位于此处)。要在表中添加一些东西,我使用 setRowData
或$ code> dataProvider 。如果我设置了断点来延迟加载表内容,表有时会包含数据。如果我以后调用表的重绘方法,表格显示正确的信息。但表应该自动加载内容。在我的项目的其他位置,我也使用datagrid,它在对话框
中工作。
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
.
我认为必须是项目绘图的错误,因为如果我在表上或不推荐的 .getDisplayedItems .getRowCount
>,它返回我正确数量的项目应该在表中。另外,如果我向表格添加选择模型并选择一个项目,则该项目包含有效数据。
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.
推荐答案
DataGrid需要放在一个LayoutPanel或Panel中实现ProvideResize接口可见。 ScrollPanel实现该接口。
DataGrid requires to be put in a LayoutPanel or Panel that implements the ProvidesResize interface to be visible. ScrollPanel implements that interface.
此外,您从DataGrid到您的根元素/面板的LayoutPanels链条必须是不间断的。在面板层次结构中似乎是这样。
Furthermore this chain of LayoutPanels from your DataGrid up to your root element/panel has to be unbroken. That seems to be the case in your panel hierarchy.
最后,您必须使用RootLayoutPanel而不是RootPanel来添加您的LayoutPanels。
那么你确定你将SimpleLayoutPanel添加到RootLayoutPanel?
Finally you have to use the RootLayoutPanel instead of the RootPanel to add your LayoutPanels.So did you make sure that you add your SimpleLayoutPanel to the RootLayoutPanel ?
另请参考这个
这篇关于GWT Datagrid不显示数据,但包含它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!