【发布时间】:2012-03-30 18:45:28
【问题描述】:
我有一个返回角色列表的方法,我想将这些角色放在 jstree 中,但我不知道如何。
我尝试执行以下操作,但我只是不知道如何为 jstree 制作有效的 json
function createNodeList() {
$('#processRoleTree').jstree({
"json_data": {
"ajax": {
"type": "POST",
"url": "/TreeLoader.aspx?Action=GetProcessRoles",
"dataType": "json",
"data": function (n) { return { id: n.attr ? n.attr("id") : 0} }
}
},
"plugins": ["json_data", "themes", "ui"]
}).bind("select_node.jstree", function (e, data) {
var selectedObj = data.rslt.obj;
alert(selectedObj.attr("id"));
});
}
在 TreeLoader.aspx 页面加载我有:
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["Action"].Equals("GetProcessRoles"))
{
GetProcessRoles();
}
}
GetProcessRoles 是我的方法,它返回 ProcessRole 对象的列表。
【问题讨论】:
标签: jquery json jquery-plugins jstree