//也能够多去试试,不会就找度娘,阿弥陀佛,贫道去也node
//实体类ajax
public class Tree
{
/// <summary>
/// 节点ID
/// </summary>
public string id { get; set; }
/// <summary>
/// 父级id
/// </summary>
public string parent { get; set; }
/// <summary>
/// 内容
/// </summary>
public string text { get; set; }json
//"{\"m_type\":\"g\"}" 能够根据该参数判断是节点子级仍是父级或者自定义
public string data { get; set; }ui
//是否有子节点
public bool children { get; set; }
}this
$('#tree_rule').jstree({
'core': {
'check_callback': true,
"data": function (obj, callback) {
$.ajax({
type: "get",
url: "数据的地址",//getAreaBuild=getTreeArea
dataType: "json",
'data': { "Phone": phone,"AccptMan": "company" //传参
},
success: function (data) {
console.info(data);
if (data.length > 0) {
callback.call(this, data);//添加数据
} else {
bootbox.alert("暂无数据!");
}
}
});
}
},
'plugins': ["sort"]
})
.bind('select_node.jstree', function (event, data) { //绑定的点击事件
var inst = data.instance;
var selectedNode = inst.get_node(data.selected);
if (data.node.text == "左" || data.node.text == "右") {
loadConfigSon(inst, selectedNode, data); 子节点加载JS方法
}
});url
//子节点加载地址事件
function loadConfigSon(inst, selectedNode, data) {
var js = {
parent: data.node.id.split('_')[0], //父节点ID
txt: data.node.text
};
$.ajax({
url: "子节点的查询方法地址",
dataType: "json",
type: "get",
data: js,
success: function (data) {
if (data.length>0) {
selectedNode.children = [];//状况自节点的数据
$.each(data, function (i, item) {//循环返回数据
inst.create_node(selectedNode, item, "last");//加载子节点数据
});
inst.open_node(selectedNode);//打开父节点
} else {
bootbox.alert("暂无数据!");
}
}
});
}get