// 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.");
}
}
});