Exemplo n.º 1
0
 public ActionResult InitMenu(string pid = "0")
 {
     try
     {
         int              id   = int.Parse(pid);
         var              temp = _menuBLL.LoadEntities(u => u.ParentId == id);
         MenuModel        menu = null;
         List <MenuModel> list = new List <MenuModel>();
         foreach (var item in temp)
         {
             menu            = new MenuModel();
             menu.id         = item.Id;
             menu.text       = item.Name;
             menu.attributes = item.LinkAddress;
             menu.iconCls    = item.Icon;
             menu.state      = temp.Select(u => u.ParentId == item.Id).Count() > 0 ? "open" : "closed";
             list.Add(menu);
         }
         return(Json(list, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json("0", JsonRequestBehavior.AllowGet));
     }
 }