Package org.gwtoolbox.widget.client.grid.selection

Examples of org.gwtoolbox.widget.client.grid.selection.SingleRowSelectionModel


        columns.setAlignment("age", ALIGN_CENTER);

        final DataGrid grid = new DataGrid(columns);
        grid.setEditInPlace(true);
        grid.setSize("100%", "250px");
        grid.setSelectionModel(new SingleRowSelectionModel());

        Record record = new MapRecord()
                .setValue("firstName", "Uri")
                .setValue("lastName", "Boness")
                .setIntValue("age", 33)
                .setValue("gender", Gender.MALE)
                .setValue("birthTime", new Time(5))
                .setValue("dutch", false);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Daan")
                .setValue("lastName", "Boness")
                .setIntValue("age", 5)
                .setValue("gender", Gender.MALE)
                .setValue("birthTime", new Time(5))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);

        record = new MapRecord()
                .setValue("firstName", "Lian")
                .setValue("lastName", "Boness")
                .setIntValue("age", 2)
                .setValue("gender", Gender.FEMALE)
                .setValue("birthTime", new Time(10))
                .setValue("dutch", true);
        grid.addRecord(record);


        final Label messageLabel = new Label();
        DOM.setStyleAttribute(messageLabel.getElement(), "marginTop", "10px");

        SimpleButton singleModelButton = new SimpleButton("Set Single Line Selection", new ClickHandler() {
            public void onClick(ClickEvent event) {
                SingleRowSelectionModel model = new SingleRowSelectionModel();
                model.addListener(new SingleRowSelectionModel.Listener() {
                    public void selectionCleared() {
                        messageLabel.setText("Selection cleared.");
                    }

                    public void rowSelected(int row, SingleRowSelection selection) {
                        messageLabel.setText("selected row " + row);
                    }
                });
                grid.setSelectionModel(model);
            }
        });

        SimpleButton multiModelButton = new SimpleButton("Set Multi-Line Selection", new ClickHandler() {
            public void onClick(ClickEvent event) {
                MultiRowSelectionModel model = new MultiRowSelectionModel();
                model.addListener(new MultiRowSelectionModel.Listener() {
                    public void selectionCleared() {
                        messageLabel.setText("Selection cleared.");
                    }

                    public void rowSelected(int row, MultiRowSelection model) {
                        messageLabel.setText("Selected rows: " + StringUtils.collectionToDelimetedString(model.getSelectedRows(), ", "));
                    }

                    public void rowUnselected(int row, MultiRowSelection model) {
                        messageLabel.setText("Selected rows: " + StringUtils.collectionToDelimetedString(model.getSelectedRows(), ", "));
                    }
                });
                grid.setSelectionModel(model);
            }
        });
View Full Code Here

TOP

Related Classes of org.gwtoolbox.widget.client.grid.selection.SingleRowSelectionModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.