2

我有一个树形文件夹结构,我使用 Fancytree 在网页中显示它,并使用lazyLoad 选项按需显示文件夹的内容。这第一次工作正常,但如果文件夹下没有项目并且展开时,由于没有项目,展开/折叠图标会消失。当我在空文件夹中创建一些文件夹时,我没有办法再次触发 ajax 调用来显示新内容。知道如何实现吗?

$("#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);
        }
    });
4

2 回答 2

3

您可以调用node.resetLazy()or node.load(true)(例如,当节点折叠时)。

有关方法的完整列表,请参见http://wwwendt.de/tech/fancytree/doc/jsdoc/FancytreeNode.html

于 2014-05-10T21:00:58.283 回答
0

即,只需在您的配置中添加一个用于折叠的事件处理程序

collapse: function(event, data){
    data.node.resetLazy();
},
于 2017-10-07T01:57:36.823 回答