jgGrid数据格式

     sb.Append(string.Concat("{\"page\":", page, ","));
            sb.Append(string.Concat("\"total\":", Math.Ceiling((decimal)soListSorted.Count / rows), ","));
            sb.Append(string.Concat("\"records\":", soListSorted.Count, ","));
            sb.Append("\"rows\":[");
            foreach (SalesOrder so in soListSorted)
            {
                sb.Append(string.Concat("{\"id\":\"", so.Id, "\","));
                //sales order id
                sb.Append(string.Concat("\"cell\":[\"", so.Id, "\","));
                //sales order external id 
                sb.Append(string.Concat("\"", so.ExternalId, "\","));
                //summary
                sb.Append(string.Concat("\"", so.Summary, "\","));
                //creater
                if (pageType.Contains("FetchToDoList"))
                    sb.Append(string.Concat("\"", so.Events[0].CreatedUser.FirstName, "\","));
                //create date
                sb.Append(string.Concat("\"", so.Events[0].CreatedDate.ToString(format).Substring(0, 10), "\","));
                //last svent info               
                sb.Append(string.Concat("\"", so.PreviousEvent.EventType.Name, " | ", so.PreviousEvent.CreatedUser.FirstName, " | ", so.PreviousEvent.CreatedDate.ToString(format), "\""));
                sb.Append("]},");

            }
            sb.Remove(sb.Length - 1, 1);
            sb.Append("]}");
            _context.Response.Write(sb.ToString());

 

 

————————————————————————————————

左后输出结果如:

{"page":1,"total":5,"records":10,"rows":[{"id":1,"cell":["aa","aa","aa"]},

                    {"id":2,"cell":["bb","bb","bb"]},

                    {"id":3,"cell":["cc","cc","cc"]}

]}

posted @ 2010-12-03 09:46  只想做好  阅读(513)  评论(0编辑  收藏  举报