This is a migrated thread and some comments may be shown as answers.

filtering + loadOnDemand issue

3 Answers 109 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bridge24
Top achievements
Rank 1
Iron
Bridge24 asked on 06 Feb 2020, 09:33 PM

If I load my treeview, then apply .filter on the root dataSource, when I open my nodes, the sub-items are all displayed, they are not filtered.

But, it works if loadOnDemand = false.

You KNOW that bug, because in that sample, you specifically set the "loadOnDemand = false" option.

https://docs.telerik.com/kendo-ui/controls/navigation/treeview/how-to/filtering/filter-out-search-results

I was able to fix it by applying the "main" filter to my nodes dataSource (node.children), on the "expand" event.

But, I think you should fix it in your source code instead!

3 Answers, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 10 Feb 2020, 04:32 PM

Hello Daniel,

The TreeView uses hierarchical dataSource and as such, the data source filters the data items client-side unless the serverFiltering option is set to true. This behavior is intended to prevent unnecessary fetching of huge datasets. Setting loadOnDemand to false will fetch all child nodes at initialization time. Otherwise only the root nodes will be fetched and child nodes will be fetched only when the user expands a parent node. In the cited article all nodes are fetched to demonstrate the possibility to filter the TreeView DataSource. You are however correct that if loadOnDemand is set to true you would need to handle the expand event, fetch all child nodes and only then apply the filtering. Note that 

If you had a different scenario in mind please share your thought, and if possible a runnable example, and we could consider the suggested improvement or provide a possible resolution of the case.

Regards,
Aleksandar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Bridge24
Top achievements
Rank 1
Iron
answered on 10 Feb 2020, 09:22 PM

Hi, what you described is the exact scenario.

I think that if I apply a filter to the "root", "loadOnDemand" true or false should not affect the results when I open the node.  The filter should be applied if I open the node after filtering the root.

Also, I did a small hack, when the node is closed, I set its pageCount to 1, allowing huge dataset to use very small DOM.
When opening, just get the pageCount back to data() size (or undefined?). 
It's night and day diffenrence on performance when having large sub-items in the hierarchical dataset. 

That is something you may include directly in your code to make the component run faster.

0
Petar
Telerik team
answered on 12 Feb 2020, 03:33 PM

Hi Bridge24,

Thank you for sharing the approach you've used to optimize the performance in the scenario you are working on. I cannot recommend it because it is not an officially tested approach but it can be useful for someone who wants to implement it on their own risk. 

Regarding the discussion, when the filter should be applied, you can submit a feature request about the desired functionality in our Feedback portal. If you decide to submit a request, please describe the pros of the functionality you suggest to be implemented.

Once in our Feedback portal, the item will be seen from the community. If there is an interest in the submitted item, and we classify it as a valid request, we might consider its implementation in the future versions of Kendo UI.

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeView
Asked by
Bridge24
Top achievements
Rank 1
Iron
Answers by
Aleksandar
Telerik team
Bridge24
Top achievements
Rank 1
Iron
Petar
Telerik team
Share this question
or