前台代码:
@using Models;@{ Layout = "~/Views/Shared/_Layout.cshtml";}
所属站点: 栏目名称: 父级栏目: 栏目列表类型: 栏目显示: 排序: 栏目图标:
后台代码:
public ActionResult GetData(){ ListsiteListAll = m_SiteDal.GetListAll(); List channelListAll = m_ChannelDal.GetListAll(); List > dicList = new List >(); foreach (cms_site_ext site in siteListAll) { Dictionary dic = new Dictionary (); dic.Add("id", "site" + site.id.ToString()); dic.Add("pId", null); dic.Add("name", site.title); dic.Add("open", "true"); dic.Add("isSite", true); //自定义属性 dicList.Add(dic); } foreach (cms_channel_ext channel in channelListAll) { Dictionary dic = new Dictionary (); dic.Add("id", channel.id.ToString()); dic.Add("pId", channel.parentId == -1 ? "site" + channel.siteId.ToString() : channel.parentId.ToString()); dic.Add("name", channel.title); dic.Add("isSite", false); //自定义属性 dic.Add("channel", channel); dic.Add("site", siteListAll.Find(a => a.id == channel.siteId)); dic.Add("parentChannel", channel.parentId == -1 ? null : channelListAll.Find(a => a.id == channel.parentId)); dicList.Add(dic); } return Json(dicList);}