红色部分:也可以使用注释的那行
$("#jstree_demo")
.jstree({
"core" : {
"animation" : 0,
"check_callback" : true,
'force_text' : true,
"themes" : { "stripes" : true },
// so that create works
"check_callback" : true,
'data' : function (obj, callback) {
var jsonstr="[]";
var jsonarray = eval('('+jsonstr+')');
$.ajax({
type: "POST",
url:url,
dataType:"json",
async: false,
success:function(result) {
var arrays= result;
for(var i=0 ; i<arrays.length; i++){
console.log(Object.getOwnPropertyNames(arrays[i]).sort());
var arr = {
"id":arrays[i].id,
"parent":arrays[i].pid==""?"#":arrays[i].pid,
"text":arrays[i].name,
"type":arrays[i].iconSkin,
"state": {"opened" : true,"selected":true}
//"state": {"selected":true}
}
jsonarray.push(arr);
}
}
});
callback.call(this, jsonarray);
}
},
"plugins" : [ "search", "state", "types", "wholerow","checkbox" ]
});