Hi, I'm not sure where to post for incubator -- it doesn't have its
own mailing list.
I'm trying to use the PagingScrollTable widget from incubator. It
seems to work just great except I cannot get the columns to sort.
>From my understanding, there is a built-in quicksort implementation
that you can override if you wish. QS should work fine for me. I
have a simple table model here with two columns (firstName, lastName)
and the datatype is a string.
A sample onModuleLoad app using the PagingScrollTable is pasted below
that sets up some mock data. I may just be using the API incorrectly,
but I can't see it. Documentation is sparse.
Anyone have any insight on this??
Thanks in advance,
Davis
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.gen2.table.client.AbstractColumnDefinition;
import com.google.gwt.gen2.table.client.CachedTableModel;
import com.google.gwt.gen2.table.client.DefaultRowRenderer;
import com.google.gwt.gen2.table.client.DefaultTableDefinition;
import com.google.gwt.gen2.table.client.FixedWidthGridBulkRenderer;
import com.google.gwt.gen2.table.client.MutableTableModel;
import com.google.gwt.gen2.table.client.PagingOptions;
import com.google.gwt.gen2.table.client.PagingScrollTable;
import com.google.gwt.gen2.table.client.ScrollTable;
import com.google.gwt.gen2.table.client.TableDefinition;
import com.google.gwt.gen2.table.client.TableModel;
import
com.google.gwt.gen2.table.client.AbstractScrollTable.SortPolicy;
import com.google.gwt.gen2.table.client.SelectionGrid.SelectionPolicy;
import com.google.gwt.gen2.table.client.TableModelHelper.Request;
import com.google.gwt.gen2.table.client.TableModelHelper.Response;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
/**
* Entry point class for the Client application.
*/
public class Client implements EntryPoint {
private CachedTableModel cachedTableModel;
private PagingScrollTable pagingScrollTable;
private DataSourceTableModel tableModel;
/**
* @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
*/
@Override
public void onModuleLoad() {
// add the scroll table
pagingScrollTable = createScrollTable();
pagingScrollTable.setHeight("200px");
RootPanel.get().add(pagingScrollTable);
// add the paging options
PagingOptions pagingOptions = new
PagingOptions(pagingScrollTable);
RootPanel.get().add(pagingOptions);
// get some mock data
List list = getMockData();
// add it to the table
showData(list);
}
private List getMockData() {
return Arrays.asList(
new ModelObject("first", "last"),
new ModelObject("bob", "jones"),
new ModelObject("harry", "smith"),
new ModelObject("nancy", "zen"));
}
private void showData(List list) {
tableModel.setData(list);
tableModel.setRowCount(list.size());
cachedTableModel.clearCache();
cachedTableModel.setRowCount(list.size());
pagingScrollTable.gotoPage(0, true);
pagingScrollTable.getDataTable().sortColumn(0);
pagingScrollTable.redraw();
}
private PagingScrollTable createScrollTable() {
tableModel = new DataSourceTableModel();
cachedTableModel = createCachedTableModel(tableModel);
TableDefinition tableDef = createTableDefinition();
PagingScrollTable scrollTable = new
PagingScrollTable(cachedTableModel, tableDef);
scrollTable.setPageSize(200);
scrollTable.setEmptyTableWidget(new HTML("There is no data to
display"));
scrollTable.getDataTable().setSelectionPolicy
(SelectionPolicy.ONE_ROW);
FixedWidthGridBulkRenderer bulkRenderer =
new
FixedWidthGridBulkRenderer(scrollTable.getDataTable
(), scrollTable);
scrollTable.setBulkRenderer(bulkRenderer);
scrollTable.setCellPadding(3);
scrollTable.setCellSpacing(0);
scrollTable.setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH);
scrollTable.setSortPolicy(SortPolicy.SINGLE_CELL);
return scrollTable;
}
private CachedTableModel createCachedTableModel
(DataSourceTableModel tableModel) {
CachedTableModel tm = new
CachedTableModel
(tableModel);
tm.setPreCachedRowCount(200);
tm.setPostCachedRowCount(200);
tm.setRowCount(1000);
return tm;
}
privat