我在
codeproject.com/script/Articles/ArticleVersion.aspx?aid=277576&av=419297阅读了有关mvc的jtable的文章
我试试看.但是在运行时,我得到错误在与服务器通信时发生错误.
请看我的代码.在控制器中
[HttpPost] public JsonResult LocalList(int jtStartIndex,int jtPageSize,string jtSorting) { try { string localCount = db.Database.sqlQuery<string>("Select Count(*) FROM Location").ToString(); IEnumerable<LOCATION> query = db.LOCATIONs; if (jtSorting.Equals("LOCATION_ID ASC")) { query = db.LOCATIONs.OrderBy(e => e.LOCATION_ID).Skip(jtStartIndex).Take(jtPageSize).ToList(); } else { query = db.LOCATIONs.OrderBy(e => e.LOCATION_ID).Skip(jtStartIndex).Take(jtPageSize).ToList(); } return Json(new { Result = "OK",Records = query,TotalRecordCount = int.Parse(localCount) }); } catch (Exception ex) { return Json(new { Result = "ERROR",Message = ex.Message }); } }
并在视图中
$('#div_local').jtable({ title: 'List Location',paging: true,//Enable paging pageSize: 10,//Set page size (default: 10) sorting: true,//Enable sorting defaultSorting: 'LOCATION_ID ASC',//Set default sorting actions: { listAction: 'HomeController/LocalList' },fields: { AREA_ID: { key: false,list: false,create: false },LOCATION_ID: { key: true,LOCATION_NAME: { title: 'Name' },LOCATION_DES: { title: 'Des' } } }); $('#div_local').jtable('load');
在这里,所有文件脚本和样式表都可以.当我看到登录chrome时,我找到了
Request URL:http://localhost:27508/HomeController/LocalList?jtStartIndex=0&jtPageSize=10&jtSorting=LOCATION_ID%20ASC Request Method:POST Status Code:404 Not Found