jquery插件treegrid树状表格的使用方法详解(.Net平(2)

public ActionResult Search(DataTable dt) { int total; IQueryable<Model.Power> powerIq = CurrentBllSession.PowerBll.GetIQueryable(); total = powerIq.Count(); List<Model.Power> powerList = powerIq.ToList(); powerList = TreeGridList(powerList); dt.recordsTotal = total; dt.recordsFiltered = total; dt.data = powerList; return Json(dt); } /// <summary> /// 将List转换为TreeGrid格式的List /// </summary> private List<Model.Power> TreeGridList(List<Model.Power> powerList) { List<Model.Power> treegridList=new List<Model.Power>(); foreach (var powerOne in powerList.Where(a => a.ParentId == "0" || a.PowerId.Length == 4).OrderBy(a => a.Sort))//一级菜单 { treegridList.Add(powerOne); foreach (var powerTwo in powerList.Where(a => a.ParentId != "0" && a.PowerId.Length == 8 && a.ParentId == powerOne.PowerId).OrderBy(a=>a.Sort))//二级菜单 { treegridList.Add(powerTwo); foreach (var powerBtn in powerList.Where(a => a.ParentId != "0" && a.PowerId.Length == 8 && a.ParentId == powerTwo.PowerId).OrderBy(a => a.Sort))//按钮 { treegridList.Add(powerBtn); } } } return treegridList; }

解释说明:

treegrid是通过tr标签上的class内容和tr的位置关系来组织表格中行之间的父子关系和位置关系的,

DT中的配置项:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwjgxd.html