How to Edit Vaadin 8 Grid.
Here goes the short snippet of the code for Editing Grid in Vaadin
Code does following.
- Takes Grid.
- populates Grid.
- makes Grid editable property true.
- sets component what one needs to add when grid is edited.
- identifies column at the time of adding column or getting column.
grid = new Grid<>(); lst = new ArrayList<>(); provider = new ListDataProvider<>(lst); lst.add(new Company(1, "Java")); grid.setDataProvider(provider); grid.addColumn(Company::getSerialNo).setCaption("Sr.no"); TextField tf = new TextField(); grid.getEditor().setEnabled(true); HorizontalLayout hlyt = new HorizontalLayout(); grid.addColumn(Company::getName).setEditorComponent(tf, Company::setName).setCaption("Name").setExpandRatio(2); hlyt.addComponent(grid);
Hope it works cheers .
Comments
Post a Comment