예제 #1
0
        public JsonResult GetData()
        {
            int page = int.Parse(Request.Form["page"]);
            string sortIndex = Request.Form["sidx"];
            string sortOrder = Request.Form["sord"];
            List<SampleModel> list = new List<SampleModel>();
            for (int i = 1; i < 200; i++)
            {
                SampleModel model = new SampleModel();
                model.productNo = i;
                model.productName1 = "제품명1_" + i.ToString();
                model.productName2 = "제품명2_" + i.ToString();
                model.productName3 = "제품명3_" + i.ToString();
                model.productCategory = "카테고리_" + i.ToString();
                model.productCategorySub = "Sub카테고리_" + i.ToString();
                model.productPrice = 1000 * i;
                model.InvoiceNo = "운송장번호" + i.ToString();
                model.TransportWay = "RR";

                model.productImage = "http://gdimg4.gmarket.co.kr/goods_image2/small_jpgimg/177/305/177305108.jpg";
                model.options = new List<ItemOptionT>();
                for (int j = 0; j < 10; j++)
                {
                    ItemOptionT o = new ItemOptionT();
                    o.OptNo = i + "" + j;
                    o.OptInfo = i + "_필수선택_" + j;
                    model.options.Add(o);
                }

                list.Add(model);
            }

            var fdata = from e in list
                        where (e.productNo > (page - 1) * 10) && (e.productNo < ((page * 10) + 1))
                        select new {
                           ck = "",
                           productNo = e.productNo,
                           productName1 = e.productName1,
                           productName2 = e.productName2,
                           productName3 = e.productName3,
                           productCategory = e.productCategory,
                           productCategorySub = e.productCategorySub,
                           productPrice = e.productPrice,
                           productImage = e.productImage,
                           invoceNo = e.InvoiceNo,
                           transportWay = e.TransportWay,
                           options = e.options
                        };
            // order by
            if (sortOrder == "desc")
            {
                if (sortIndex == "productNo")
                {
                    fdata = fdata.OrderByDescending(m => m.productNo);
                }
            }
            else
            {
                if (sortIndex == "productNo")
                {
                    fdata = fdata.OrderBy(m => m.productNo);
                }
            }

            var result = new
            {
                total = Math.Ceiling(Convert.ToDecimal(Convert.ToDecimal(list.Count) / 10)),
                page = page,
                rows = fdata.ToArray()
            };

            return Json(result);
        }
예제 #2
0
 public JsonResult subGrid(int idx)
 {
     List<SampleModel> list = new List<SampleModel>();
     for (int i = 0; i < 10; i++)
     {
         SampleModel model = new SampleModel();
         model.sub_option = string.Format("옵션{0}_{1}" , idx, i);
         list.Add(model);
     }
     return Json(list, JsonRequestBehavior.AllowGet);
 }