[Script]
$.ajax({
url: "/Home/GetFilters",
type: "POST",
dataType: "json",
success: function (data) {
$("#tree1").ejTreeView({
height: "300px",
fields: {
id: "ID_CATEGORIE", text: "CAT_TEXT", parentId: "CAT_ID_PARENT", dataSource: data, hasChild: "hasChild", expanded: "expanded",
},
showCheckbox: true
});
},
});
[controller]
public JsonResult GetFilters()
{
List<CATEGORIE> treeData = GetTreeData();
var categories = (from n in treeData.OrderBy(a => a.CAT_TEXT)
select new
{
ID_CATEGORIE = n.ID_CATEGORIE,
CAT_TEXT = n.CAT_TEXT,
CAT_ID_PARENT = n.CAT_ID_PARENT,
hasChild = n.hasChild,
expanded = n.expanded
}).ToList();
return Json(categories, JsonRequestBehavior.AllowGet);
}
|