components
components copied to clipboard
[Tree][NestedTreeDataSource] filter doesn't work
Provide a general summary of the issue here
We need to implement a search funtion for a lazy loaded tree, see the screenshot.
However the addFilter method of NestedTreeDataSource doesn't work and throws an not implemented error
Uncaught Error: Filtering is not yet supported in tree data sources.
at NestedTreeDataSource.addFilter (tree-data-source.js:40:11)
at SubjectSelection.search_fn (subject-selection.ts:318:24)
๐ค Expected Behavior?
NestedTreeDataSource should support filters.
๐ฏ Current Behavior
๐ Possible Solution
๐ฅ๏ธ Steps to Reproduce
this.dataSource = new NestedTreeDataSource(data, { ... });
if (detail) {
const regex = new RegExp(detail, 'i');
this.dataSource?.addFilter('search', (item: LazyNestedDataNode) => regex.test(item.name));
} else {
this.dataSource?.removeFilter('search');
}
this.dataSource?.update();
What browsers are you seeing the problem on? (only for bugs in code)
Safari, Chrome
If other, please specify.
No response
What operating system are you using?
WSL
๐ค Your name
Frans de Boer
๐งข Your product/team
Magister
๐จ Your Theme(s)
Magister
Probably a duplicate of #2749