jstree里的data要一次全加载完么?
能不能通过id动态取节点?

解决方案 »

  1.   

    我的JS是这样:
    URL是一个servlet.
    <script type="text/javascript">
    $(function() {
    $("#menu").tree( {
    data : {
            type  : "json",
            url   : "Tree",
            async : true,
            async_data : function (NODE) { 
                    return { id : 100000, my_param : "1" } 
            }
          },
          ui : {
              dots        : false,     // BOOL - dots or no dots
              rtl         : false,    // BOOL - is the tree right-to-left
              animation   : 0,        // INT - duration of open/close animations in miliseconds
              hover_mode  : true,     // SHOULD get_* functions chage focus or change hovered item
              scroll_spd  : 4,
              theme_path  : "themes/",    // Path to themes
              theme_name  : "classic"// Name of theme
          },
          
          callback    : {  
              onselect    : function(NODE,TREE_OBJ) {
              var id  = $(NODE).attr("id");
              alert(id);
           }  
    }
    });
    });
    </script>
      

  2.   

    <script type="text/javascript">
    $(function() {
    $("#menu").tree( {
    data : {
    type : "json",
    url : "Tree",
    async : true,
    async_data : function (NODE) { 
    return { id : 100000, my_param : "1" } 
    }
    },
    ui : {
    dots : false, // BOOL - dots or no dots
    rtl : false, // BOOL - is the tree right-to-left
    animation : 0, // INT - duration of open/close animations in miliseconds
    hover_mode : true, // SHOULD get_* functions chage focus or change hovered item
    scroll_spd : 4,
    theme_path : "themes/", // Path to themes
    theme_name : "classic"// Name of theme
    },
     
    callback : {  
    onselect : function(NODE,TREE_OBJ) {
    var id = $(NODE).attr("id");
    alert(id);
    }  
    }
    });
    当然可以了 不过要注意你用的版本
      

  3.   

    data : {
            type  : "json",
            url   : "Tree",
            async : true,
            async_data : function (NODE)                    return { parent_Id : $(NODE).attr("id") || 0}  

           }
    为什么我不可以把 async_data 属性里的parent_Id将节点的ID传到后台,然后再通过ID获取该节点下的子节点么?