示例#1
0
        public static string select_wiki(this HtmlHelper helper)
        {
            B_Wiki       b_wiki = new B_Wiki();
            List <Order> order  = new List <Order>()
            {
                Order.Asc("sort_id")
            };
            List <SearchTemplate> st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "parent_id", value = 0, searchType = Common.EnumBase.SearchType.Eq
                }
            };
            var           list_wiki = b_wiki.GetList(st, order);
            StringBuilder sb        = new StringBuilder();

            sb.Append("<select id=\"txt_parent_id\" name=\"txt_parent_id\" class=\"selectpicker show-tick form-control\" data-live-search=\"true\">");
            sb.Append("<option selected = \"selected\" data-subtext=一级栏目>" + 0 + "</option>");
            for (int i = 0; i < list_wiki.Count; i++)
            {
                sb.Append("<option data-subtext=" + list_wiki[i].title + ">" + list_wiki[i].id + "</option>");
            }
            sb.Append("</select>");
            return(sb.ToString());
        }
示例#2
0
        public JsonResult GetWikiList(int limit = 10, int offset = 1)
        {
            B_Wiki       b_wiki = new B_Wiki();
            List <Order> order  = new List <Order>()
            {
                Order.Asc("sort_id")
            };

            List <SearchTemplate> st = new List <SearchTemplate>()
            {
                new SearchTemplate()
                {
                    key = "parent_id", value = 0, searchType = Common.EnumBase.SearchType.Eq
                },
                new SearchTemplate()
                {
                    key = "", value = new int[] { offset, limit }, searchType = Common.EnumBase.SearchType.Paging
                }
            };
            List <Domain.Wiki> list = new List <Wiki>();

            var list_wiki = b_wiki.GetList(st, order);

            foreach (var item in list_wiki)
            {
                list.Add(item);
                st = new List <SearchTemplate>()
                {
                    new SearchTemplate()
                    {
                        key = "parent_id", value = item.id, searchType = Common.EnumBase.SearchType.Eq
                    }
                };
                var sub_wiki = b_wiki.GetList(st, order);
                list.AddRange(sub_wiki);
            }


            var total = b_wiki.GetCount(st);

            return(Json(new { total = total, rows = list }, JsonRequestBehavior.AllowGet));
        }