我假设您要制作一张显示您的小桌子行的大桌子:
table1 table2
col1 | col2 | col3 col1 | col2 | col3 | col4
------------------ -------------------------
a | b | c 1 | 2 | 3 | 4
big table
col1 | col2 | col3 | col1 | col2 | col3 | col4
----------------------------------------------
a | b | c | 1 | 2 | 3 | 4
与例如
CellTable<String[]> table1 = new CellTable<String[]>();
table1.addColumn(new Column<String[], String>(new TextCell()){
public String getValue(String[] object){
return object[0];
}
}, "col1");
此解决方案仅适用,如果你可以编辑源代码构建小桌子!
我首先定义一个行对象类,它包含大表中单个行的全部信息,例如,
public class RowObject{
public String[] table1RowObject; // the class of the field should be the generic
// type of the table1 CellTable
public MyObject table2RowObject; // the class of the field should
// be the generic type of table2
// ... other tables
}
现在改变泛型类型的小表来RowObject
:
CellTable<RowObject> table1 = new CellTable<RowObject>();
table1.addColumn (new Column<RowObject, String>(new TextCell()){
public String getValue(RowObject object){
// The data of table1 has been moved into the table1RowObject
// old: String[] object; return object[0];
return object.table1RowObject[0];
}
}, "col1");
那么大的表可以很容易地构造这样的:
CellTable<RowObject> bigTable = new CellTable<RowObject>();
for (CellTable<RowObject> ct : tablesList){
for (int i = 0; i < ct.getColumnCount(); i++)
bigTable.addColumn(ct.getColumn(i));
}
加载数据的所有表同时在数据提供者的帮助下,例如,
ListDataProvider<RowObject> dataSource = new ListDataProvider<RowObject>();
dataSource.addDataDisplay(table1);
dataSource.addDataDisplay(table2);
dataSource.addDataDisplay(bigTable);
,然后只要你更新dataSource
所有的小表,可能得到在同一时间为大表进行更新。