Change TreeView Datasource from remote to local

5 posts, 0 answers
  1. Grant
    Grant avatar
    164 posts
    Member since:
    Jul 2016

    Posted 19 Jan 2017 Link to this post

    Hi, 

    I have a treeview which loads its nodes dynamically on expand, which works fine. I also have a button to 'Expand All' to open all nodes as far as the tree goes.

    Unfortunately I have no way of knowing how big the tree is or how deep it goes until the data is loaded. So instead of recursively calling '.expand()' until there are no more closed nodes (which would make 10's of server requests for data), I would rather Retrieve the entire tree, and reset the dataSource to a local one that contains all the entire tree.

    I'm having some trouble though, when I reset the DS to local and expand a node, the tree is still making a request call which retrieved the entire tree again as node contents. Note that I am also trying to set loadOnDemand to false, but its having no affect.

    Any advice on this scenario would be great.

    Thanks,
    Grant

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1207 posts

    Posted 23 Jan 2017 Link to this post

    Hello Grant,

    Here you will find a Dojo sample, implementing the described scenario. The TreeView is initially configured to work with remote DataSource. On click of the button the DataSource is changed to a local one, using the setDataSource() method. Then all the nodes are expanded.

    May I ask you to modify the above, so it reproduces the issue faced at your end and send back to us?

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Grant
    Grant avatar
    164 posts
    Member since:
    Jul 2016

    Posted 23 Jan 2017 in reply to Veselin Tsvetanov Link to this post

    Hi Veselin,

    Thanks for the helpful response. Unfortunately I must apologize. After re-reading my question, I realized that my code did not represent the question I was asking. So I apologize for wasting your time. When I reset the DS I was setting it to another remote location that returned a full Hierarchical tree. It obviously isn't static and so wouldn't be treated as such by kendo.

    I has however lead me to a related question. I've updated your example with an additional level under 'Occasional Furniture', and I noticed that when you call .expand('.k-item'), it only expands the first level of nodes. Is there a way to recuse the expanding until the end of the tree, without knowing what nodes the tree contains (cannot use expandPath() or expandTo() as I wont know what the tree will contain)?

    Thanks and kind regards,
    Grant

  4. Grant
    Grant avatar
    164 posts
    Member since:
    Jul 2016

    Posted 24 Jan 2017 in reply to Grant Link to this post

    I've managed to resolve this issue by surrounding the .expand() with a while..do.

    FYI: http://dojo.telerik.com/ALOsa/6

    Thanks anyway,
    Grant

  5. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    1207 posts

    Posted 24 Jan 2017 Link to this post

    Hello Grant,

    Thank you for getting back to us and letting us know how you have approached the discussed scenario.

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top