Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I solved the issue by modifying Google's ListDataProviderExample to use CellTable. Since the number of Columns is not known at compile time, I used the IndexedColumn class by Thomas Broyer (<a href="https://stackoverflow.com/questions/7172262/create-gwt-celltable-dynamically">Create GWT CellTable Dynamically</a>) as referred to by Juan Pablo Gardella (<a href="https://groups.google.com/forum/?fromgroups=#!topic/google-web-toolkit/v6vZT0eUQKU" rel="nofollow noreferrer">https://groups.google.com/forum/?fromgroups=#!topic/google-web-toolkit/v6vZT0eUQKU</a>). Here is my test code:</p> <pre><code>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&lt;List&lt;String&gt;&gt; table = new CellTable&lt;List&lt;String&gt;&gt;(); // 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 &lt; nrows; irow++) { List&lt;String&gt; rowL = Arrays.asList(rowsA[irow]); rowsL.add(rowL); } // Create table columns for (int icol = 0; icol &lt; ncols; icol++) { table.addColumn(new IndexedColumn(icol), new TextHeader(rowsA[0][icol])); } // Create a list data provider. final ListDataProvider&lt;List&lt;String&gt;&gt; dataProvider = new ListDataProvider&lt;List&lt;String&gt;&gt;(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&lt;List&lt;String&gt;, String&gt; { private final int index; public IndexedColumn(int index) { super(new TextCell()); this.index = index; } @Override public String getValue(List&lt;String&gt; object) { return object.get(this.index); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload