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

Insert Node INTO / As a child of an existing node

1 Answer 580 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Coty
Top achievements
Rank 1
Coty asked on 18 Feb 2015, 02:21 PM
hi there,  I have a kendo treeview.

This treeview has 2 levels, parent nodes and children nodes.  Some top level nodes don't have children.  A user can add or remove nodes at any level.  To add a top level node I use append.  To add a child node I use insertAfter.  What I haven't figured out is how to add a node as a child to a top level node that previously had no children before it.  Essentially I need to know how to add the First Child to an existing node.

Thanks,

Coty

1 Answer, 1 is accepted

Sort by
0
Coty
Top achievements
Rank 1
answered on 18 Feb 2015, 07:16 PM
Ah I found the answer in the documentation, I must have missed it the first 5 times I went through it!

treeview.append({
    Id: data,
    Order: order,
    Name: name,
    HasNotes: false,
    HasAttachments: false,
    template: kendo.template($("#treeview-template").html())
}, ParentNode);

You just pass the parent node into the append function...



Tags
TreeView
Asked by
Coty
Top achievements
Rank 1
Answers by
Coty
Top achievements
Rank 1
Share this question
or