List of usage examples for com.google.gwt.gen2.table.client AbstractScrollTable setSortPolicy
public void setSortPolicy(SortPolicy sortPolicy)
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.sort.SortColumnOption.java
License:Apache License
@Override protected Widget onInitialize() { CustomForm form = new CustomForm(); // Add the current policy policyBox = new ListBox(); policyBox.addItem("Disabled"); policyBox.addItem("Single Cell"); policyBox.addItem("Multi Cell"); form.addLabeledWidget("Sort Policy:", policyBox); refreshPolicy();/* w w w . j a v a 2 s. c o m*/ // Add button to change policy { Button button = new Button("Set Sort Policy", new ClickHandler() { public void onClick(ClickEvent event) { AbstractScrollTable scrollTable = ScrollTableDemo.get().getScrollTable(); switch (policyBox.getSelectedIndex()) { case 0: scrollTable.setSortPolicy(SortPolicy.DISABLED); break; case 1: scrollTable.setSortPolicy(SortPolicy.SINGLE_CELL); break; case 2: scrollTable.setSortPolicy(SortPolicy.MULTI_CELL); break; } } }); form.addButton(button); } // Select the column index final TextBox columnBox = new TextBox(); columnBox.setText("3"); columnBox.setWidth("50px"); form.addLabeledWidget("Column Index:", columnBox); // Add a button to sort the column { Button button = new Button("Sort Column", new ClickHandler() { public void onClick(ClickEvent event) { try { int column = Integer.parseInt(columnBox.getText()); ScrollTableDemo.get().getDataTable().sortColumn(column); ScrollTableDemo.get().getScrollTable().redraw(); } catch (NumberFormatException e) { Window.alert("Please enter valid integers for the row and column."); } catch (IndexOutOfBoundsException e) { Window.alert("The row or column index you entered is out of bounds."); } } }); form.addButton(button); } // Add a button to make column sortable if (PagingScrollTableDemo.get() == null) { Button button = new Button("Make Sortable", new ClickHandler() { public void onClick(ClickEvent event) { try { int column = Integer.parseInt(columnBox.getText()); ScrollTable scrollTable = (ScrollTable) ScrollTableDemo.get().getScrollTable(); scrollTable.setColumnSortable(column, true); } catch (NumberFormatException e) { Window.alert("Please enter valid integers for the row and column."); } } }); form.addButton(button); } // Add a button to make column unsortable if (PagingScrollTableDemo.get() == null) { Button button = new Button("Make Unsortable", new ClickHandler() { public void onClick(ClickEvent event) { try { int column = Integer.parseInt(columnBox.getText()); ScrollTable scrollTable = (ScrollTable) ScrollTableDemo.get().getScrollTable(); scrollTable.setColumnSortable(column, false); } catch (NumberFormatException e) { Window.alert("Please enter valid integers for the row and column."); } } }); form.addButton(button); } return form; }