List of usage examples for com.google.gwt.gen2.table.event.client ColumnSortEvent getColumnSortList
public ColumnSortList getColumnSortList()
From source file:org.gwtaf.widgets.search.SearchResultScrollTable.java
License:Apache License
private void setValue(List<SearchResult> results, boolean saveFullResult) { // store the full results if necessary. if (saveFullResult) { fullResults = new DynamicSearchResults(); fullResults.setResults(results); }//from w w w.jav a2 s . co m // nothing to do if there are no results. if (results == null) { return; } // figure out how many columns we'll need int neededColumns = results.size() == 0 ? 0 : results.get(0).getDataValues().length; // make a new data grid this.dataGrid = createDataGrid(results.size(), neededColumns); dataGrid.setCellSpacing(0); // pass on the cell selection handler dataGrid.addCellClickHandler(clickHandler); // pass on the handler dataGrid.addRowSelectionHandler(rowSelectionHandler); // add handler for sorting dataGrid.addColumnSortHandler(new ColumnSortHandler() { public void onColumnSorted(ColumnSortEvent event) { lastSortedColumn = event.getColumnSortList().getPrimaryColumn(); lastSortDirection = event.getColumnSortList().isPrimaryAscending(); markOdd(); } }); int dataGridIndex = 0; // set the values into the list for (int i = 0; i < results.size(); i++) { // if not null if (results.get(i) != null) { setSingleResult(results.get(i), dataGridIndex); dataGridIndex++; } } /** * Creating a new header table. Cannot re-use the old one due to * scrolltable not supporting remove. (one parent widget constraint) */ FixedWidthFlexTable newHeaderTable = new FixedWidthFlexTable(); for (int i = 0; i < headerTable.getColumnCount(); i++) { newHeaderTable.setHTML(0, i, headerTable.getHTML(0, i)); } // replace the scrolltable ScrollTable newTable = new ScrollTable(dataGrid, newHeaderTable); newTable.setSortPolicy(SortPolicy.SINGLE_CELL); newTable.setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH); this.scrollTable = newTable; mainPanel.clear(); mainPanel.setWidget(0, 0, newTable); }