如何通过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); }