1
我有一個方法返回一個角色列表,我想把這些角色放在jstree中,但我不知道如何。有效的json動態創建一個jstree節點
我試着做以下,但我只是不知道如何做一個有效的JSON用於jstree
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對象的列表。
好的,謝謝你!只是我不知道該回到哪裏?!在我的GetProcessRole方法? – HRI 2012-03-14 10:29:53
好的,我認爲你的技術使用的是web服務,試着用asp開發web服務,用c#http://williamsportwebdeveloper.com/cgi/wp/?p=494 – viyancs 2012-03-14 10:35:35
我們不能添加attr,使用Ajax來獲取JSON? – HRI 2012-03-14 11:59:26