GWT数据网格不可见(UIBinder和LazyPanel)
我正在构建一个GWT应用程序 在这个应用程序中,我有许多DataGrid实现,显示从服务器检索到的数据。在一个面板中,我有一个TabLayoutPanel,每个选项卡上都有一个DataGrid 当父选项卡变为可见时,我试图延迟加载数据网格 以下是ui.xml文件:GWT数据网格不可见(UIBinder和LazyPanel),gwt,datagrid,uibinder,Gwt,Datagrid,Uibinder,我正在构建一个GWT应用程序 在这个应用程序中,我有许多DataGrid实现,显示从服务器检索到的数据。在一个面板中,我有一个TabLayoutPanel,每个选项卡上都有一个DataGrid 当父选项卡变为可见时,我试图延迟加载数据网格 以下是ui.xml文件: <g:TabLayoutPanel width="800px" height="450px" barUnit='EM' barHeight='3'> <g:tab> <g:header size='7
<g:TabLayoutPanel width="800px" height="450px" barUnit='EM' barHeight='3'>
<g:tab>
<g:header size='7'><b>Volunteer Assignments</b></g:header>
<grid:VolunteerAssignmentGrid/>
</g:tab>
<g:tab>
<g:header size='7'><b>Volunteer Details</b></g:header>
<g:LazyPanel ui:field="lazyDetails">
<grid:VolunteerFieldsGrid/>
</g:LazyPanel>
</g:tab>
</g:TabLayoutPanel>
志愿者任务
志愿者详情
在上面的代码中,志愿者分配网格和志愿者字段网格是DataGrid的子类
志愿者分配网格立即可见,数据显示OK
但是,下一个选项卡上的志愿者字段网格根本不显示
奇怪的是,它在正确的时间(当我单击另一个选项卡时)请求数据,并且服务器响应是正确的。这张桌子好像不可见
你知道为什么第二个数据网格不可见吗
编辑:
UiBinder类:
public class VolunteerDetailsPanel extends DialogBox {
interface Binder extends UiBinder<Widget, VolunteerDetailsPanel> {}
private static final Binder binder = GWT.create(Binder.class);
@UiField LazyPanel lazyDetails;
private Record volunteerRecord;
private String fullName;
private String volunteerId;
public VolunteerDetailsPanel(Record record) {
this.volunteerRecord = record;
fullName = volunteerRecord.getValue("forename")+" "+volunteerRecord.getValue("surname");
volunteerId = volunteerRecord.getValue("id");
setText(fullName);
}
public void initComponent() {
setWidget(binder.createAndBindUi(this));
}
@UiFactory VolunteerAssignmentGrid createAssignmentGrid() {
return new VolunteerAssignmentGrid(volunteerId, fullName);
}
@UiFactory VolunteerFieldsGrid createFieldsGrid() {
return new VolunteerFieldsGrid(volunteerId);
}
}
public类扩展对话框{
接口绑定器扩展UiBinder{}
私有静态最终绑定器Binder=GWT.create(Binder.class);
@UiField LazyPanel lazyDetails;
私人档案;
私有字符串全名;
私有字符串ID;
公共志愿者详细信息(记录){
this.record=记录;
fullName=fullrecord.getValue(“名字”)+“”+fullrecord.getValue(“姓氏”);
志愿者id=志愿者记录.getValue(“id”);
setText(全名);
}
公共组件(){
setWidget(binder.createAndBindUi(this));
}
@UIAssignmentGrid CreateSignmentGrid(){
返回新的志愿者分配网格(志愿者ID,全名);
}
@UIFieldsGrid createFieldsGrid(){
返回新的志愿者FieldsGrid(志愿者ID);
}
}
根据要求,志愿者也参加了FieldsGrid课程。它扩展了ListGrid(我的一个,但是太长了,无法在这里发布,我的所有其他网格都扩展了它,并且都正常),这反过来又扩展了GWT的DataGrid:
public class VolunteerFieldsGrid extends ListGrid {
public VolunteerFieldsGrid(String volunteerId) {
super(100, "name", false);
setWidth("100%");
ListGridColumn<?>[] columns = new ListGridColumn<?>[] {
new FieldNameColumn("Field", "name").width(75),
new TextColumn("Value", "value").width(300)
};
setColumns(columns);
ListGridDataProvider data = ListGridDataProvider.getInstance("field",
"/volunteer/"+volunteerId, "name", false);
setDataProvider(data);
}
}
public类字段grid扩展ListGrid{
公共志愿者字段Grid(字符串志愿者ID){
超级(100,“名称”,假);
设置宽度(“100%”);
ListGridColumn[]columns=新建ListGridColumn[]{
新字段名称列(“字段”、“名称”)。宽度(75),
新文本列(“值”、“值”)。宽度(300)
};
设置列(列);
ListGridDataProvider data=ListGridDataProvider.getInstance(“字段”,
“/志愿者/”+志愿者ID,“姓名”,假);
setDataProvider(数据);
}
}
您必须在表格LayoutPanel
中注册SelectionEvent
的处理程序,该处理程序将调用LazyPanel.setVisible(true)
。在UiBinder中尝试以下操作:
@UiHandler("yourTabPanelUiField")
void onSelectionEvent(SelectionEvent event) {
//for extra functionality check if EventTarget equals the correct tab
lazyDetails.setVisible(true);
}
你能显示uibinder模板的所有者和志愿者字段网格吗?额外信息按要求添加。不幸的是,这不起作用。我开始怀疑一个GWT错误,因为如果我在LazyPanel下嵌套另一个TagLayoutPanel,其中一个标签显示我的网格,它就可以工作了!