Adding a subtree under a already rendered tree node

6 posts, 0 answers
  1. Craig
    Craig avatar
    12 posts
    Member since:
    Jun 2011

    Posted 15 Feb 2017 Link to this post

    So I have done my initial loading of the TreeList with datasource read. During that time I cache off the DataSourceTransportOptions passed into the read method

    This tree shows fine initially but I am trying to then load a subtree with many nodes under a user selected node.  I download the partial subtree  of data and have the id's and parentId's set properly and use the cached DataSourceTransportOptions to call options.success(myCompleteList).  My expectation is that my data would be inserted into the correct location but it appears to screw up the id's and parentId's of the rendered data.

    I have confirmed that the id's and parent id's of my data is correct just that the view is not.

    Obviously, I am doing something wrong or perhaps it is a limitation that I cannot build up a tree a subtree at a time.

    -Craig

     

  2. Stefan
    Admin
    Stefan avatar
    2913 posts

    Posted 17 Feb 2017 Link to this post

    Hello Craig,

    I was not able to reproduce the described issue on my end.

    Still, in this scenario, I can suggest using the data method of the dataSource to retrieve the current tree data, then add the new tree to it and set the new data using again the data method:

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data

    I made a Dojo example demonstrating this implementation:

    http://dojo.telerik.com/IsEzI

    I hope this is helpful.

    Regards,
    Stefan
    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. Craig
    Craig avatar
    12 posts
    Member since:
    Jun 2011

    Posted 21 Feb 2017 in reply to Stefan Link to this post

    Hi Stefan,

    The suggestion to add it directly to the datasource.data() seemed to do the trick.  We have used the technique of reusing the options.success() after the initial load with other controls but the this control seemed to not like this.

    Thanks

    Craig

  4. Omar
    Omar avatar
    2 posts
    Member since:
    Dec 2014

    Posted 12 Sep 2017 in reply to Stefan Link to this post

    Hello Stefan,

        In your dojo example:

    http://dojo.telerik.com/IsEzI

        If the data objects rename the attributes "id" for "att_id" and "parentId" for "att_parentId" and consider such changes for the model in the TreeDataSource :

    model: {
       id: "att_id",
       fields : {
          parentId : { field: "att_parentId", nullable: true }
       }
    }

    The subtree is not loaded, is such behavior a bug?
  5. Stefan
    Admin
    Stefan avatar
    2913 posts

    Posted 14 Sep 2017 Link to this post

    Hello Omar,

    When the names are different this is expected because the data method will not use the schema.model configuration to parse the set data items.

    http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#methods-data

    "The schema.model configuration will not be used to parse the set data items. The data should be parsed in advance and the values should be provided in the correct type - date values should be JavaScript Date objects, numeric values should be JavaScript numbers, and others."

    In this case, the new objects have to have a parentId instead of some_name_parentId.

    Regards,
    Stefan
    Progress Telerik
    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.
  6. Omar
    Omar avatar
    2 posts
    Member since:
    Dec 2014

    Posted 18 Sep 2017 in reply to Stefan Link to this post

    Hello Stefan,

    Excellent! ... Thanks a lot for the clarification.

    Regards.

Back to Top