how to expand the async treeview node

2 posts, 1 answers
  1. xu
    xu avatar
    5 posts
    Member since:
    Sep 2012

    Posted 13 Sep 2012 Link to this post

    my treeview ::
        var opcPath = "";
        var dataSource = new{
            transport: {
                read: {
                    url: "../fwp/getOPCTree.fwp?opcPath=" + opcPath,
                    type: "GET",
                    dataType: "json"
            schema: {
                model: {
                    id: "opcPath",
                    hasChildren: "hasChildren"
        treeview = $("#opcTreeView").kendoTreeView({
            select: onOPCTreeSelect,
            dataSource: dataSource,
            dataTextField: "nodeName",
            dataSpriteCssClassField: "nodeCSS",
            dataImageUrlField: "imageUrl"

    the treeview is async!!!!
    i can get the id "opcpath".
    when the root is expand, 
    but the child is not expand,
    then i want to expand the child child child .....node through the id.
    how  to do??
  2. Answer
    Nohinn avatar
    167 posts
    Member since:
    Feb 2011

    Posted 14 Sep 2012 Link to this post

    Use the change event of the dataSource.
    dataSource: {
        change: function(e) {
            if(e.items.length > 0 && e.action == "itemchange") {
                 // your code to look for the new node to expand here

    Then expand your root node through the uid attribute (as the treeview has it's own findByUid method).
    var t = $('#TreeView').data('kendoTreeView');

    When it expands and is going to add the children nodes it will fire the change event, if you need to keep opening more nodes you will have to do the same within the change event (look for the node and expand it).
Back to Top