javascript - 面对超过 2000 个项目时,Dynatree 返回错误

标签 javascript json dynatree

我使用 dynatree 并且一切正常,但如果节点有大量项目,我会收到错误消息。我已经阅读了有关设置 enableUpdate(false); 功能的信息,但它也没有帮助。有什么想法吗?

var serviceParams = { Type: this._fieldName };

$("#tree").dynatree({       
    autoFocus: false,
    clickFolderMode: 1,     
    initAjax: {
        url: tree._serviceUrl + "/top",
        data: jQuery.serializeJSON(serviceParams),
        type: "POST",
        contentType: "application/json; charset=utf-8",
        dataType: "json"
    },

    onLazyRead: function(node) {        

        //this.enableUpdate(false);    

        var serviceParamsForChildren = 
        { 
            Type: tree._fieldName, 
            parentId: node.data.key, 
            includeDescedants: false 
        };

        node.appendAjax({
            url: tree._serviceUrl + "/Children",
            data: jQuery.serializeJSON(serviceParamsForChildren),
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json"
        });

        //this.enableUpdate(true);
    },
    onActivate: function(node) {
       tree._selectedNode = node;
    }
});

最佳答案

根据 docs

tree.enableUpdate(启用)

Turn rendering on or off and return the previous mode. Disabling update may speedup processing, when adding lots of nodes. Don't forget to turn rendering back on, after applying the changes

关于javascript - 面对超过 2000 个项目时,Dynatree 返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8434095/

相关文章:

javascript - 将 MVC 模型序列化为 JSON

php - json_encode PHP 数组作为 JSON 数组而不是 JSON 对象

jquery - 单击链接 <a> 时 Dynatree 取消选择节点(或删除事件类)

javascript - 如何将这三个功能重构为一个?

javascript - Gulp 和 Browserify,使用 Node.js require(); 进行依赖管理。把 jQuery 放在上面?

javascript - 如何在 crafty.js 中使用多个碰撞箱区域?

javascript - Google Recaptcha Ajax 响应奇怪的检查顺序

javascript - 在 HTML : Uncaught TypeError: data. forEach 中使用 JSON 文件不是函数

javascript - 使用 JavaScript 设置自定义属性

javascript - 用新数据重新加载 dynatree - destroy 方法或 reloadChildren 似乎不起作用