TreeGrid is populated with following structure and text field in header cell. Filter is always returning true for root items and comparing only child items for equality.
Primary
Red
Yellow
Blue
Intermediate
Orange
Green
Purple
Parent node has expand icon even when filter hides all children. When expand is clicked all expand/collapse nodes gets unresponsive.
Expected result would be at least not to freeze the tree grid. Even better would be if the expand icon would not be shown when children are filtered out.
Example code of UI.init method initializing TreeGrid.
@Override
protected void init(VaadinRequest vaadinRequest) {
setSizeFull();
final VerticalLayout layout = new VerticalLayout();
layout.setSizeFull();
TreeGrid<TreeGridRow> grid = new TreeGrid<>(TreeGridRow.class);
TreeData<TreeGridRow> treeData = new TreeData<>();
TreeDataProvider<TreeGridRow> treeDataProvider = new TreeDataProvider<>(
treeData);
TreeGridRow parent1 = new TreeGridRow("Primary");
TreeGridRow parent2 = new TreeGridRow("Intermediate");
treeData.addRootItems(Arrays.asList(parent1, parent2));
treeData.addItems(parent1, Arrays.asList(new TreeGridRow("Red"),
new TreeGridRow("Yellow"), new TreeGridRow("Blue")));
treeData.addItems(parent2, Arrays.asList(new TreeGridRow("Orange"),
new TreeGridRow("Green"), new TreeGridRow("Purple")));
grid.setDataProvider(treeDataProvider);
grid.setSelectionMode(SelectionMode.NONE);
TextField nameFilter = new TextField();
nameFilter.setWidthFull();
nameFilter.addValueChangeListener(f -> treeDataProvider
.setFilter(new SerializablePredicate<TreeGridRow>() {
private static final long serialVersionUID = 1L;
@Override
public boolean test(TreeGridRow t) {
if (treeData.getRootItems().contains(t)) {
return true;
}
return Optional.of(t.getName()).orElse("")
.contains(Optional.of(f.getValue()).orElse(""));
}
}));
grid.getDefaultHeaderRow().getCell("name").setComponent(nameFilter);
layout.addComponents(grid);
setContent(layout);
}
Vaadin 8.14.3
TreeGrid is populated with following structure and text field in header cell. Filter is always returning true for root items and comparing only child items for equality.
Primary
Intermediate
Parent node has expand icon even when filter hides all children. When expand is clicked all expand/collapse nodes gets unresponsive.
Expected result would be at least not to freeze the tree grid. Even better would be if the expand icon would not be shown when children are filtered out.
Example code of UI.init method initializing TreeGrid.