Example: Treeview load on demand - append to selected node

1 posts, 0 answers
  1. Johnny
    Johnny avatar
    1 posts
    Member since:
    Jun 2012

    Posted 09 Jun 2012 Link to this post

    Greetings,
    After spending a great deal of time trying to get this to work, I finally found a simple solution. Call the tree.append and pass the new item and current node as a jquery object.

    treeview.append({ text: "new item text" }, $(e.node))

    here is a simple sample on jsfiddle... http://jsfiddle.net/jldoubleu/BSUFs/1/

    Also, the sample code.
    var treeview = null
    $(document).ready(function() {
     
        treeview = $("#tree").kendoTreeView({
            select: onItemSelected,
            dataSource: [{text: "A"},{text: "B"},{text: "C"},{text: "D"}]
        }).data("kendoTreeView");
     
        function onItemSelected(e) {
            for (var ictr = 0; ictr < 5; ictr++) {
                treeview.append({ text: e.node.innerText + "-" + ictr}, $(e.node))
            }
        }
    });

    Enjoy...
Back to Top