7

我正在使用带有通过 AJAX 加载数据的选项的 jsTree ( 1.0-rc3 ),我在加载大约 2000 个子节点时遇到问题。虽然服务器会在几秒钟内做出响应,但 jsTree 仅需要大约 40 秒才能在浏览器中呈现结果(chrome、FF)。除此之外,FF 从 'jquery-1.7.2.min.js' 返回关于没有响应的信息。相同数量的数据冻结 IE。数据是否超载?或者它是某种错误?是否有任何可变因素可以帮助我加快渲染速度?

jQuery( "#dependency-tree" ).jstree(
        {
            'plugins':['themes', 'json_data', 'ui', 'core', 'types', 'sort'],
            "json_data":{
                "progressive_render": true,
                "data":initData,
                cache:false,
                "ajax":{
                    "url":function ( node )
                    {
                        return appContext + 'GetUnitsNode/'
                            + node.attr( 'id' );
                    },
                    dataType:"text",
                    "success":function ( data )
                    {
                        if ( data == "none" )
                        {
                            return false;
                        }
                        return jQuery.parseJSON( data );
                    }
                }
            },
            "ui":{
                'select_limit':1
            },
            "core":{
                'animation':0,
                'html_titles':true
            },
            "themes":{
                "theme":"rules",
                "dots":true,
                "icons":true
            },
            "types":{
                "types":{
                    "default":{
                        "icon":{
                            "image":appContext + "/img/orange.png"
                        }
                    }
                }
            },
            "sort":function ( a, b )
            {
               return this.get_text( a ).toUpperCase() > this.get_text( b ).toUpperCase() ? 1 : -1;
            }
        } ).bind( "select_node.jstree", function ( event, data )
        {
            submitedNodeId = data.rslt.obj.attr( 'id' );
            submitedNodeTypeId = data.rslt.obj.attr( "typeId" );
            submitedNodeLast = data.inst.is_leaf( data.rslt.obj );
            g_node_text = jQuery( data.rslt.obj ).children().eq(1).html();
        } );
4

1 回答 1

2

你有没有尝试过?

  • 渐进式渲染

    progress_render 一个布尔值。默认为假。如果此选项设置为 true,则仅将返回的 JSON 的可见(打开节点)部分转换为 DOM 节点,任何隐藏部分都将被保存并按需解析(当节点变为可见时)。当你有一个会导致大量 DOM 的大型嵌套树时,这很有用

  • AJAX 加载

于 2012-11-25T22:09:17.040 回答