Forcefully calling transport read method on every expand click

3 posts, 0 answers
  1. Sushant
    Sushant avatar
    5 posts
    Member since:
    Jun 2012

    Posted 18 Jul 2012 Link to this post

    Currently treeview calls transport read method when we first time click on expand. After that the data is cached.
    I want to call read method forcefully so that dynamically added nodes are refreshed in tree.
    Is there a way to give a serverside read call on every expand button click?
  2. Pakeeru
    Pakeeru avatar
    4 posts
    Member since:
    Jul 2012

    Posted 19 Jul 2012 Link to this post

    the below code can help you..

    please have this in the node expand event.

    $("#treeview").kendoTreeView({
                 dataSource: Categories,            
                 expand: onExpand,
                dataTextField: ["Name", "Name"]           
            });
     
    function onExpand(e) {
                $("[data-role=treeview]").data("kendoTreeView")
            .bind("expand", function (e) {
                this.dataItem(e.node).loaded(false);
            })
            .bind("collapse", function (e) {
                setTimeout(function () {
                    $(e.node).children(".k-group,.k-animation-container").remove();
                }, this.options.animation.collapse.duration);
            })
        }
  3. Sushant
    Sushant avatar
    5 posts
    Member since:
    Jun 2012

    Posted 19 Jul 2012 Link to this post

    this still doesn't work. The reason being, tree view caches data by default. So when you click on subsequest expand, it loads tree from cache.
    I added cache: false attribute on transport read method for tree view and now it does a server call for every expand.

    transport: {
                    read: {
                        url: document.URL + "/GetOrgUnitTree/",
                        dataType: "json",
                        cache: false
                    }

    Thanks,
    Sushant
Back to Top