本文介绍了jstree绑定json数据从控制器mvc发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
My controller
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public JsonResult GetAllNodes()
{
List<Employee> pEmployee = new List<Employee>();
Employee tEmployee = new Employee();
tEmployee.EMP_ID = 1;
tEmployee.EMP_NAME = "steve";
tEmployee.PARENT_EMP_ID = 0;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 2;
tEmployee.EMP_NAME = "Joe";
tEmployee.PARENT_EMP_ID = 1;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 3;
tEmployee.EMP_NAME = "Eric";
tEmployee.PARENT_EMP_ID = 1;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 4;
tEmployee.EMP_NAME = "Henry";
tEmployee.PARENT_EMP_ID = 0;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 5;
tEmployee.EMP_NAME = "Katie";
tEmployee.PARENT_EMP_ID = 4;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 6;
tEmployee.EMP_NAME = "george";
tEmployee.PARENT_EMP_ID = 4;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 7;
tEmployee.EMP_NAME = "Renai";
tEmployee.PARENT_EMP_ID = 0;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 8;
tEmployee.EMP_NAME = "Marc";
tEmployee.PARENT_EMP_ID = 7;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 9;
tEmployee.EMP_NAME = "John";
tEmployee.PARENT_EMP_ID = 7;
pEmployee.Add(tEmployee);
tEmployee = new Employee();
tEmployee.EMP_ID = 10;
tEmployee.EMP_NAME = "Andrew";
tEmployee.PARENT_EMP_ID = 0;
pEmployee.Add(tEmployee);
return Json(pEmployee, JsonRequestBehavior.AllowGet);
// return pEmployee;
}
View
<script type="text/javascript">
$(document).ready(function () {
$.getJSON("Employee/GetAllNodes", function (result) {
alert(result);
alert(JSON.stringify(result));
$("#treeViewDiv").jstree({
"plugins": ["themes", JSON.stringify(result)]
});
});
});
</script>
Now the issue is that when result comes from controller ,it doesnt bind to jstree.How to bind the data to jstree.
推荐答案
Now the issue is that when result comes from controller ,it doesnt bind to jstree.How to bind the data to jstree.
这篇关于jstree绑定json数据从控制器mvc发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!