Hi at all, this is not working, why?
TreeGrid<Resource> treeGrid = new TreeGrid<>(Resource.class);
TreeData<Resource> data = treeGrid.getTreeData();
TreeDataProvider<Resource> dataProvider = new TreeDataProvider<>(data);
treeGrid.setHierarchyColumn("name");
Resource dad1 = new Resource("dad1", null, null, null);
Resource dad2 = new Resource("dad2", null, null, null);
Resource dad3 = new Resource("dad3", null, null, null);
data.addRootItems(dad1);
data.addRootItems(dad2);
data.addRootItems(dad3);
treeGrid.setDataProvider(dataProvider);
TextField filterTextField = new TextField();
filterTextField.setPlaceholder("name filter");
filterTextField.setValueChangeMode(ValueChangeMode.EAGER);
filterTextField.addValueChangeListener(event -> {
dataProvider.setFilter(Resource::getName, name -> {
String nameLower = name == null ? "" : name.toLowerCase(Locale.ENGLISH);
String filterLower = event.getValue().toLowerCase(Locale.ENGLISH);
return nameLower.contains(filterLower);
});
});