我正在尝试在智能 gwt 中向 ListGrid 添加行。正在添加行,但未显示值
public class SearchResultsView extends HLayout {
public SearchResultsView(EmployeeServiceAsync empServiceAsync) {
final ListGrid employeeGrid = new ListGrid();
employeeGrid.setWidth(500);
employeeGrid.setHeight(224);
employeeGrid.setShowAllRecords(true);
ListGridField empIDField = new ListGridField("empID", "Employee Id");
ListGridField empNameField = new ListGridField("empName",
"Employee Name");
employeeGrid.setFields(empIDField, empNameField);
// Employee[EmployeeData.getRecords().size()]);
empServiceAsync.getRecords(new AsyncCallback<List<Employee>>() {
@Override
public void onSuccess(List<Employee> result) {
System.out.println(result);
/*
Employee[] employee = result.toArray(new Employee[result.size()]);
employeeGrid.setData(employee);*/
EmployeeListGrid employeeListGrid[]=new EmployeeListGrid[result.size()];
int counter=0;
for (Employee employee : result) {
employeeListGrid[counter]=new EmployeeListGrid(employee.getEmpID(), employee.getEmpName());
System.out.println(employeeListGrid[counter].getEmpID()+">>"+employeeListGrid[counter].getEmpName());
counter++;
}
employeeGrid.setData(employeeListGrid);
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
});
this.addChild(employeeGrid);
}
}
说明>> 为了填充网格,我正在对服务器进行 rpc 调用,服务器返回一个列表。我迭代列表并创建一个 EmployeeListGrid 类型的对象数组(因为 EmployeeListGrid 扩展 ListGridRecord )。然后用创建的数组喂给employeegrid。
我在这里错过了什么吗,为什么网格显示空行?
请注意,我已经调试并确保正确填充了“employeeListGrid”,但未呈现内容。