Example usage for com.google.gwt.gen2.table.client SelectionGrid setSelectionEnabled

List of usage examples for com.google.gwt.gen2.table.client SelectionGrid setSelectionEnabled

Introduction

In this page you can find the example usage for com.google.gwt.gen2.table.client SelectionGrid setSelectionEnabled.

Prototype

public void setSelectionEnabled(boolean enabled) 

Source Link

Document

Enable or disable row selection.

Usage

From source file:com.google.gwt.gen2.demo.scrolltable.client.option.highlight.RowSelectionPolicyOption.java

License:Apache License

@Override
protected Widget onInitialize() {
    CustomForm form = new CustomForm();

    // Add the current status
    statusLabel = new Label();
    form.addLabeledWidget("Selection Status:", statusLabel);

    // Add the current policy
    policyBox = new ListBox();
    policyBox.addItem("Multi Row");
    policyBox.addItem("Single Row");
    policyBox.addItem("Checkboxes");
    policyBox.addItem("Radio Buttons");
    form.addLabeledWidget("Selection Policy:", policyBox);

    // Add button to change policy
    {//from w w  w . jav  a  2s . co  m
        Button button = new Button("Set Selection Policy", new ClickHandler() {
            public void onClick(ClickEvent event) {
                SelectionGrid grid = ScrollTableDemo.get().getDataTable();
                switch (policyBox.getSelectedIndex()) {
                case 0:
                    grid.setSelectionPolicy(SelectionPolicy.MULTI_ROW);
                    break;
                case 1:
                    grid.setSelectionPolicy(SelectionPolicy.ONE_ROW);
                    break;
                case 2:
                    grid.setSelectionPolicy(SelectionPolicy.CHECKBOX);
                    break;
                case 3:
                    grid.setSelectionPolicy(SelectionPolicy.RADIO);
                    break;
                }
                PagingScrollTableDemo.get().getPagingScrollTable().reloadPage();
            }
        });
        form.addButton(button);
    }

    // Add button to change status
    {
        Button button = new Button("Toggle Status", new ClickHandler() {
            public void onClick(ClickEvent event) {
                SelectionGrid grid = ScrollTableDemo.get().getDataTable();
                grid.setSelectionEnabled(!grid.isSelectionEnabled());
                refreshPolicy();
            }
        });
        form.addButton(button);
    }

    // Refresh policy and return
    refreshPolicy();
    return form;
}