Hello!
I have one specific problem. I need to create new column by click the button. It means → I want have about 20 new colums without properties. And when i try this → It was always a big problem. Please help me with that.
public class MyUI extends UI {
private CustomerService service = CustomerService.getInstance();
private Grid<Customer> grid = new Grid<>(Customer.class);
private TextField filterText = new TextField();
@Override
protected void init(VaadinRequest vaadinRequest) {
final VerticalLayout layout = new VerticalLayout();
Button clearFilterTextBtn = new Button(FontAwesome.TIMES);
clearFilterTextBtn.setDescription("Clear the current name");
clearFilterTextBtn.addClickListener(e -> filterText.clear());
CssLayout filtering = new CssLayout();
filtering.addComponents(filterText, clearFilterTextBtn);
filtering.setStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
Button addCustomerBtn = new Button("Pridaj zamestnanca");
Button downloadXlsBtn = new Button("Stiahnuť ako .xls");
Button loginBtn = new Button("Prihlásiť sa");
Button backBtn = new Button("Vlož");
downloadXlsBtn.setVisible(false);
TextField name = new TextField();
PasswordField pass = new PasswordField();
addCustomerBtn.setStyleName(ValoTheme.BUTTON_PRIMARY);
addCustomerBtn.setClickShortcut(KeyCode.ENTER);
loginBtn.setClickShortcut(KeyCode.ENTER);
backBtn.addClickListener(evt -> {
//Here i want have adding the new columns
grid.addColumn("Something") //It doesn't work
});
HorizontalLayout toolbar = new HorizontalLayout(name, pass, loginBtn,filtering, addCustomerBtn,backBtn,downloadXlsBtn);
grid.setColumns("datum", "lastName");
HorizontalLayout main = new HorizontalLayout(grid);
main.setSizeFull();
grid.setSizeFull();
grid.getColumn("datum").setWidth(100);
grid.getColumn("datum").setCaption("Date");
grid.getColumn("lastName").setCaption("Last Name");
layout.addComponents(toolbar, main);
updateList();
setContent(layout);
}
My error:
A Grid created without a bean type class literal or a custom property set doesn't support finding properties by name.