arrow_back history picture_as_pdf This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ~~NOTRANS~~ ~~Title: Vaadin UI code snippets~~ We have a list of useful code snippets for you. Simply use them for your application. All snippets are free to use and licensed under [[https://www.apache.org/licenses/LICENSE-2.0|Apache 2.0]]. ==== Checkbox in Table Header ==== If you want to show a checkbox in the table header of a v7 Table: {{:vaadin:checkbox_tableheader.png?nolink|}} use following code: <file java> book.getRowDefinition().getColumnDefinition("CHECK").setSortable(false) book.getRowDefinition().getColumnDefinition("CHECK") .setLabel("<input type='checkbox' id='checkboxSelectAll' onclick=\"selectAllListener(this.checked)\" " + "style=\"position:absolute;top: 2px;\"/>"); </file> and to receive events from the checkbox: <file java> JavaScript.getCurrent().addFunction("selectAllListener", new JavaScriptFunction() { public void call(JsonArray arguments) { System.out.println("Pressed!"); } }); </file> ==== Checkbox in Grid Header ==== If you want to show a checkbox in the header of a Grid: {{:vaadin:grid_checkbox.png?nolink|}} use following code: <file java> CheckBox cbx = new CheckBox(); cbx.addValueChangeListener(new ValueChangeListener<Boolean>() { @Override public void valueChange(ValueChangeEvent<Boolean> event) { System.out.println("Pressed!"); } }); UIFactoryManager.getFactory().invokeLater(() -> { // Cast the resource to a Grid. ((Grid)((VaadinGrid)navLoggings.getUIResource()).getResource()) // Get the first (automatically added) row. .getHeaderRow(0) // Get the cell for the column we want. .getCell("CHECK") // Add the component. .setComponent(cbx); }); </file>