控制器层
///
/// 树形 数据权限
///
///
public ActionResult SelectDiseaseData()
{
try
{
List<S_Disease> Disease = mymodel.S_Disease.ToList();
List<Vo.zTreeVo> MyzTreeVo = new List<Vo.zTreeVo>();
Vo.zTreeVo zTreeVo = new Vo.zTreeVo();
zTreeVo.id = 0;
zTreeVo.pId = 0;
zTreeVo.name = “数据权限”;
zTreeVo.open = true;
zTreeVo.iconOpen = “/Content/img/1_close.png”;
zTreeVo.iconClose = “/Content/img/1_open.png”; ;
MyzTreeVo.Add(zTreeVo);
var FunctionaAuthorityID = 0;
foreach (var item in Disease)
{
FunctionaAuthorityID = item.DiseaseID;
Vo.zTreeVo ForzTreeVo = new Vo.zTreeVo();
ForzTreeVo.id = FunctionaAuthorityID;
ForzTreeVo.pId = 0;
ForzTreeVo.name = item.DiseaseMC;
ForzTreeVo.title = item.DiseaseMC;
ForzTreeVo.open = true;
ForzTreeVo.icon = “/Content/img/2.png”;
MyzTreeVo.Add(ForzTreeVo);
}
return Json(MyzTreeVo, JsonRequestBehavior.AllowGet);
}
catch (Exception e)
{
Console.WriteLine(e);
return null;
}
}
视图层
var setting = {
check: {
enable: true
},
data: {
key: {
title: "title"
},
simpleData: {
enable: true
}
}
};
//树形 数据权限
$.post("/RoleManagement/RoleEdit/SelectDiseaseData", function (data) {
if (data != null) {
$.fn.zTree.init($("#treeDemoData"), setting, data);
}
});