//下面為后臺獲取樹JSON格式的方法,但不知如何去判斷checked是否被選中,如果直接設定為@checked=true,則所有的節點都會被選中
我想的結果是只根據條件來選中,并回傳給前端顯示.
public ActionResult GetRoleAuthMenu(int RoleID)
{
//1.查旬所有權限
var allData = authorize.Select(u=>true);
var allsum = allData.Count();//總行數
//2.查詢要給角色分配權限時,該角色已經擁有的權限
var rolData = roleauth.Select(u=>u.RoleID==RoleID);
var rolsum = rolData.Count();//總行數
//3.查詢數狀結構資料
bool ck = false;//復選框是否選中狀態
var mydata = from x in allData
where x.ParentID == 0 && x.Type == "選單"
select new
{
//第一層根節點
id = x.AuthID,
ParentID = x.ParentID,
title = x.AuthName,
spread = true,
children = from y in allData
where y.ParentID == x.AuthID
select new
{
//第二層
id = y.AuthID,
ParentID = y.ParentID,
title = y.AuthName,
spread = true,
children = from z in allData
where z.ParentID == y.AuthID
select new
{
//第三層
id = z.AuthID,
ParentID = z.ParentID,
title = z.AuthName,
spread = true,
@checked = ck //此處ck需根據條件來顯示是否選中復選框,如果直接設定@checked =true,
//會把所有的復選框都選中了
}
}
};
return Json(mydata, JsonRequestBehavior.AllowGet);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/175537.html
標籤:ASP
上一篇:事關微信支付,別成為背鍋俠!
下一篇:canvas Transform
