Search code examples
kendo-uikendo-treeviewkendo-datasource

Kendo treeView Server Filtering with Load on demand


I want to have something similar to the example here http://demos.telerik.com/kendo-ui/treeview/filter-treeview-in-dialog but with some changes which are

  • Server side filtering
  • remote datasource
  • Load on demand true (when no search)

For example, the expected behaviour is initially the tree will be loaded from remote datasource with load on demand (only first level will be retrieved) and when user enter a search text, the search will be performed on server side and all results will be returned and no lazy loading. last thing when user clear search text, the tree will return to lazy loading again and load on demand would be true.

And here are more details about my case

  • Tree Structure will be only two levels, let say type and item

  • root level is fixed, all roots will always shown

  • first json object structure which will be used in all data retrieval will be

    • Id
    • Description
    • HasChild
    • Childs
  • so data will be retrieved from the server as following

    • first load will be the root level only, has child will be true for all roots, and children will be null
    • when expand node (with lazy loading), only return the children for the expanded node
    • when search (will not lazy loading), return all roots with matched children in children property

Any ideas?


Solution

  • as Ross Bush says, it is not a built in functionality, after a lot of tries and research, i found that the issue is two things:

    1. I cannot change the load on demand after initialization (even i use setOptions function)
    2. I cannot change the value of children after datasource intialized !!!

    so, the solution (or acutally a workaround) is re-intialize the datasource and the tree when i change the mode from search to view and vise versa !!!. this is how i solved it

    Thanks all for your contributing