2

I have a tree folder structure that I am displaying in a webpage using Fancytree and using the lazyLoad option to display the contents of the folder ondemand. This works fine for the first time, but if there are no items under a folder and when expanded, since there are no items, the icon to expand/collapse disappears. When i create some folders in at empty folder, I dont have a way to fire an ajax call again to display the new contents. Any idea how this can be achieved?

$("#officialTreeView").fancytree({  
        extensions: ["table"],
        aria: true,
        source: {
            url: "myurl/jsonoutput", 
            data: {key: "1" },
            cache: false
        },
        lazyLoad: function(event,data) {
            var node = data.node;   
            //data.node.load(true);             
            // Issue an ajax request to load child nodes
            data.result = { cache:false, url: "myurl/jsonoutput", data: {key: node.key } }
        },          
        renderColumns: function(event, data) {
            var node = data.node,               
                $tdList = $(node.tr).find(">td");
            //console.log(node);    
            $tdList.eq(1).text(node.data.childcount);
        }
    });
tshepang
  • 12,111
  • 21
  • 91
  • 136
user980591
  • 31
  • 1
  • 3

2 Answers2

3

You can call node.resetLazy() or node.load(true) (for example when a node is collapsed).

See http://wwwendt.de/tech/fancytree/doc/jsdoc/FancytreeNode.html for a complete list of methods.

mar10
  • 14,320
  • 5
  • 39
  • 64
0

i.e just add an event handler for collapse to your config

collapse: function(event, data){
    data.node.resetLazy();
},
Zac Spitzer
  • 74
  • 1
  • 6