Search in sources :

Example 1 with DeleteButtonRenderer

use of org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer in project GridFastNavigation by TatuLund.

the class DemoUI method initGrid.

private void initGrid(final Grid grid) {
    grid.setEditorEnabled(true);
    // Add some columns
    DeleteButtonRenderer deleteButton = new DeleteButtonRenderer(new DeleteRendererClickListener() {

        @Override
        public void click(DeleteRendererClickEvent event) {
            grid.getContainerDataSource().removeItem(event.getItem());
        }
    }, FontAwesome.TRASH.getHtml() + " Delete", FontAwesome.CHECK.getHtml() + " Confirm");
    deleteButton.setHtmlContentAllowed(true);
    grid.addColumn("action", Boolean.class);
    grid.getColumn("action").setEditable(false);
    grid.getColumn("action").setRenderer(deleteButton);
    grid.addColumn("col1", String.class);
    grid.addColumn("col2", String.class);
    for (int i = 0; i < 5; ++i) {
        grid.addColumn("col" + (i + 3), Integer.class);
    }
    TextField field = new TextField();
    field.addValidator(new IntegerRangeValidator("The value needs to be between 0 and 10", 0, 40));
    grid.getColumn("col3").setEditorField(field);
    grid.addColumn("col8", Date.class);
    grid.addColumn("col10", Boolean.class);
    grid.addColumn("col11", String.class);
    ComboBox comboBox = new ComboBox();
    comboBox.addItems("Soft", "Medium", "Hard");
    grid.getColumn("col11").setEditorField(comboBox);
    // Make column 2 read only to test statically read only columns
    grid.getColumn("col2").setEditable(false);
    Random rand = new Random();
    for (int i = 0; i < 100; ++i) {
        grid.addRow(true, "string 1 " + i, "string 2 " + i, rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), rand.nextInt(i + 10), new Date(), false, "Medium");
    }
    grid.setSelectionMode(SelectionMode.SINGLE);
    grid.setSizeFull();
}
Also used : IntegerRangeValidator(com.vaadin.data.validator.IntegerRangeValidator) DeleteRendererClickListener(org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer.DeleteRendererClickListener) Random(java.util.Random) ComboBox(com.vaadin.ui.ComboBox) TextField(com.vaadin.ui.TextField) DeleteButtonRenderer(org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer) DeleteRendererClickEvent(org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer.DeleteRendererClickEvent) Date(java.util.Date)

Aggregations

IntegerRangeValidator (com.vaadin.data.validator.IntegerRangeValidator)1 ComboBox (com.vaadin.ui.ComboBox)1 TextField (com.vaadin.ui.TextField)1 Date (java.util.Date)1 Random (java.util.Random)1 DeleteButtonRenderer (org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer)1 DeleteRendererClickEvent (org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer.DeleteRendererClickEvent)1 DeleteRendererClickListener (org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer.DeleteRendererClickListener)1