Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To show multiple column in table you need to put array in list. The reference code to achieve this is: </p> <pre><code>package com.test.client; import java.util.ArrayList; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.cellview.client.CellTable; import com.google.gwt.user.cellview.client.SimplePager; import com.google.gwt.user.cellview.client.TextColumn; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.view.client.ListViewAdapter; import com.google.gwt.view.client.SingleSelectionModel; public class Index implements EntryPoint { public void onModuleLoad() { // create some data ArrayList&lt;String[]&gt; values = new ArrayList&lt;String[]&gt;(); values.add(new String[] { "1", "a" }); values.add(new String[] { "2", "b" }); values.add(new String[] { "3", "c" }); values.add(new String[] { "4", "d" }); values.add(new String[] { "5", "e" }); values.add(new String[] { "6", "f" }); values.add(new String[] { "7", "g" }); values.add(new String[] { "8", "h" }); values.add(new String[] { "9", "i" }); values.add(new String[] { "10", "j" }); // create a ListViewAdapter ListViewAdapter&lt;String[]&gt; lva = new ListViewAdapter&lt;String[]&gt;(); // give the ListViewAdapter our data lva.setList(values); RootPanel.get().add(new HTML("&lt;hr /&gt;")); { // CellTable CellTable&lt;String[]&gt; ct = new CellTable&lt;String[]&gt;(); ct.setSelectionEnabled(true); ct.setSelectionModel(new SingleSelectionModel()); ct.setPageSize(2); lva.addView(ct); ct.addColumn(new TextColumn&lt;String[]&gt;() { @Override public String getValue(String[] object) { return object[0]; } }, "First"); ct.addColumn(new TextColumn&lt;String[]&gt;() { @Override public String getValue(String[] object) { return "%" + object[1] + "%"; } }, "Second"); // create a pager, giving it a handle to the CellTable SimplePager&lt;String[]&gt; pager = new SimplePager&lt;String[]&gt;(ct, SimplePager.TextLocation.CENTER); // add the Pager to the page RootPanel.get().add(pager); // add the CellList to the page RootPanel.get().add(ct); } } } </code></pre>
 

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