I read this article about jtable with mvc at codeproject.com/script/Articles/ArticleVersion.aspx?aid=277576&av=419297
I am trying this. But when I start, I get an error. An error occured while communicating to the server.
Look at my code. In the controller
[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 });
}
}
And in the view
$('
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,
list: false,
create: false
},
LOCATION_NAME: {
title: 'Name'
},
LOCATION_DES: {
title: 'Des'
}
}
});
$('
Here the whole script file and style sheet are in order. When I see a magazine in chrome, I found
Request URL:http://localhost:27508/HomeController/LocalList?jtStartIndex=0&jtPageSize=10&jtSorting=LOCATION_ID%20ASC
Request Method:POST
Status Code:404 Not Found
Can you tell me what the error is or what is happening here? and how to fix it. Thanks guys.
source
share