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