首页 新闻 会员 周边 捐助

bootgird ajax mvc

0
悬赏园豆:50 [已关闭问题] 关闭于 2016-09-05 15:29

如何通过ajax取到数据,我从服务端取回数据,结果只有Id列有数据,还都是undefined,我是这样写的 还什么不对 还望指教

HTML

  <table id="grid-data" class="table table-condensed table-hover table-striped">
        <thead>
            <tr>
                <th data-column="Id" data-type="numeric" data-identifier="true">Id</th>
                <th data-column="Demo1">Demo1</th>
                <th data-column="Demo2">Demo2</th>
                <th data-column="Demo3">Demo3</th>
            </tr>
        </thead>
    </table>

js

 $('#grid-data').bootgrid({
        ajax: true,
        rowCount: 10,
        ajaxSettings: {
            method: "POST",
            cache: true
        },
        requestHandler: function (request) {
            request.sortItems = [];
            if (request.sort == null)
                return request;
            for (var property in request.sort) {
                if (request.sort.hasOwnProperty(property)) {
                    request.sortItems.push({ Field: property, Type: request.sort[property] });
                }
            }
            return request;
        },
        responseHandler: function (response) {
            var a = 1;
            return response;
        },
        url: '/Home/GetMyData'
    })

服务端

[HttpPost]
        public ActionResult GetMyData(BootgridRequestData model)
        {
            demoEntities context = new demoEntities();
            T_Demo td = new T_Demo();
            IEnumerable<T_Demo> list = context.T_Demo.AsEnumerable<T_Demo>();
            BootgridResponseData<T_Demo> bgrd = new BootgridResponseData<T_Demo>();
            bgrd.current = model.current;
            bgrd.rowCount = model.rowCount;
            bgrd.rows = list;
            bgrd.total = list.Count();

            return Json(bgrd);

        }
咖啡漩涡的主页 咖啡漩涡 | 初学一级 | 园豆:193
提问于:2016-08-19 09:09
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册