首页 新闻 会员 周边 捐助

jqGrid 将json如何在绑定的

0
[已关闭问题] 关闭于 2013-04-10 14:29

json: var jsonData = new
            {
                total = totalPages,
                page = page,
                records = totalRecords,
                rows = new
                {

                    city = "bj",
                    district = "bj",
                    telphone = "010-8888888",
                    createTime = "2011-1-1",
                    address = "everywhere in beijing",
                    name = "KFC"
                }
            };

 

 

Controller:public JsonResult GetJsonData(string sidx, string sord, int page, int rows)
        {
            string json = Request["sp"] == null ? "" : Request["sp"].ToString();
            JqGridModel jqGridModel = new JqGridModel();

            Object obj = jqGridModel.GridData(sidx, sord, page, rows);
           
           
            return Json(obj, JsonRequestBehavior.AllowGet);
           
        }

 

 

js:jQuery().ready(
        function () {
            jQuery("#list1").jqGrid(
                    {
                        url: '/Home/GetJsonData',
                        datatype: "json",
                        mtype:"GET",
                        colNames: ['姓名', '地区', '城市', '地址', '电话', '创建时间'],
                        colModel: [
                            { name: 'name', index: 'name', width: 75 },
                            { name: 'district', index: 'district', width: 90 },
                            { name: 'city', index: 'city', width: 100 },
                            { name: 'rows.address', index: 'address', width: 160 },
                            { name: 'telphone', index: 'telphone', width: 80 },
                            { name: 'createTime', index: 'createTime', width: 150, sortable: true }
                        ],
                        rowNum: 10,
                        autowidth: true,
                        height: 'auto',
                        pager: jQuery('#pager1'),
                        sortname: 'name',
                        viewrecords: true,
                        sortorder: "desc",
                        caption: "商户列表",
                        jsonReader: {
                            total: "total",
                            page: "page",
                            records: "records",
                            //root: function (obj) {
                               
                            //    var jsondata = eval('(' + obj + ')');
                                
                            //    return jsondata.rows;
                            //},
                            root:"rows",
                            repeatitems: false,
                        },
                        multiselect: true
                    });
        });

xinshen的主页 xinshen | 初学一级 | 园豆:167
提问于:2013-04-10 12:53
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册