に大きなString[][]
配列を表示してFlexTable
いますが、非常に遅いです。またはで配列を表示するにはどうすればよいですCellTable
かDataGrid
?
例を示しますが、 、、 のCellTable< some class>
ようなものが欲しいだけです。CellTable< String>
CellTable< String[]>
CellTable< List< String> >
に大きなString[][]
配列を表示してFlexTable
いますが、非常に遅いです。またはで配列を表示するにはどうすればよいですCellTable
かDataGrid
?
例を示しますが、 、、 のCellTable< some class>
ようなものが欲しいだけです。CellTable< String>
CellTable< String[]>
CellTable< List< String> >
Google の ListDataProviderExample を変更して CellTable を使用することで問題を解決しました。コンパイル時には列の数がわからないため、Juan Pablo Gardella ( https://groups.google.com/forum/?fromgroups=# !topic/google-web-toolkit/v6vZT0eUQKU )。ここに私のテストコードがあります:
package com.google.gwt.examples.view.client;
import com.google.gwt.cell.client.TextCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.Column;
import com.google.gwt.user.cellview.client.TextHeader;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.ListDataProvider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ListDataProviderExample implements EntryPoint {
String[][] rowsA = {{"aaaaa","bbbbb","ccccc"},
{"111", "222", "333"}, {"A", "B", "C"}};
public void onModuleLoad() {
// Create a CellTable.
CellTable<List<String>> table = new CellTable<List<String>>();
// Get the rows as List
int nrows = rowsA.length;
int ncols = rowsA[0].length;
ArrayList rowsL = new ArrayList(nrows);
//List rowsL = new ArrayList(nrows);
for (int irow = 0; irow < nrows; irow++) {
List<String> rowL = Arrays.asList(rowsA[irow]);
rowsL.add(rowL);
}
// Create table columns
for (int icol = 0; icol < ncols; icol++) {
table.addColumn(new IndexedColumn(icol),
new TextHeader(rowsA[0][icol]));
}
// Create a list data provider.
final ListDataProvider<List<String>> dataProvider
= new ListDataProvider<List<String>>(rowsL);
// Add the table to the dataProvider.
dataProvider.addDataDisplay(table);
// Add the widgets to the root panel.
VerticalPanel vPanel = new VerticalPanel();
vPanel.add(table);
RootPanel.get().add(vPanel);
}
}
class IndexedColumn extends Column<List<String>, String> {
private final int index;
public IndexedColumn(int index) {
super(new TextCell());
this.index = index;
}
@Override
public String getValue(List<String> object) {
return object.get(this.index);
}
}