Home > front end >  Layui tree do permissions, checkboxes, how to judge whether the selected according to the condition,
Layui tree do permissions, checkboxes, how to judge whether the selected according to the condition,

Time:10-17

//the method to get the background trees JSON format below, but I don't know how to judge whether checked to be selected, if set to @ directly checked=true, then all the nodes will be selected to
I think the result is only selected according to the conditions, and returned to the front-end display.

Public ActionResult GetRoleAuthMenu (int RoleID)
{
//1. Check all permissions of ten-day
Var allData=https://bbs.csdn.net/topics/authorize.Select (u=> true);
Var allsum=allData. The Count ();//total number of rows

//2. Query for role division limit, the role has permissions
Var rolData=https://bbs.csdn.net/topics/roleauth.Select (u=> u.R oleID==RoleID);
Var rolsum=rolData. The Count ();//total number of rows

//3. The number of query structure data
bool ck=false;//check box is selected
Var mydata x=https://bbs.csdn.net/topics/from in allData
Where x.P arentID==0 & amp; & X.T ype=="menu"
Select new
{
//the first layer of the root node
Id=x.A uthID,
ParentID=x.P arentID,
Title=x.A uthName,
Spread=true,
Children=the from y in allData
Where y.P arentID==x.A uthID
Select new
{
//the second
Id=y.A uthID,
ParentID=y.P arentID,
Title=y.A uthName,
Spread=true,
Children from z=allData in
Where z.P arentID==y.A uthID
Select new
{
//the third layer
Id=z.A uthID,
ParentID=z.P arentID,
Title=z.A uthName,
Spread=true,
@ checked=ck//ck here according to the conditions needed to show whether select the checkbox, if directly set @ checked=true,
//will all the check boxes checked the

}
}
};

Return a Json (mydata, JsonRequestBehavior. AllowGet);

}
  •  Tags:  
  • ASP