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

Forcefully calling transport read method on every expand click

2 Answers 109 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Sushant
Top achievements
Rank 1
Sushant asked on 18 Jul 2012, 08:33 PM
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 Answers, 1 is accepted

Sort by
0
Pakeeru
Top achievements
Rank 1
answered on 19 Jul 2012, 05:33 PM
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);
        })
    }
0
Sushant
Top achievements
Rank 1
answered on 19 Jul 2012, 09:25 PM
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
Tags
TreeView
Asked by
Sushant
Top achievements
Rank 1
Answers by
Pakeeru
Top achievements
Rank 1
Sushant
Top achievements
Rank 1
Share this question
or