use of org.vaadin.grid.cellrenderers.action.DeleteButtonRenderer.DeleteRendererClickListener 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();
}
Aggregations