Hi everyone, i noticed that in a datagrid with resizable columns if I append a row the resizable feature is in the appended row and not in the first row. Am i doing something wrong?
Hello!
This is a default behavior in Vaadin Grid. There is a GitHub issue in Vaadin, but is still not resolved: appendHeaderRow should not move select-all and resizing controls away from default header row [2d] · Issue #1054 · vaadin/flow-components · GitHub
To enable resizing in first header row, add the following code after appending header row:
@ViewComponent
private DataGrid<User> usersDataGrid;
@Subscribe
public void onInit(final InitEvent event) {
HeaderRow headerRow = usersDataGrid.appendHeaderRow();
// configure header row...
// Make resizable first header row
usersDataGrid.getAllColumns().forEach(c ->
c.getElement().getParent().callJsFunction("setAttribute", "resizable", true));
}
Thanks that works