iDisplayStart is set incorrectly when pressing "Next"
iDisplayStart is set incorrectly when pressing "Next"
Hi.
I use datatables with server side processing and when pressing Next I get a very strange behavior. If "1" is selected in pagination links, it works ok; however, if page "2" is currently selected, pressing next will set iDisplayStart to the value "1010" which corresponds to page 102.
This is my initialization code:
oTable = $('#solutionsTable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bSort": false,
"oLanguage": {
"sSearch": "Search all columns:"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": '@Url.Action("AsyncGetUserData")',
"bDeferRender": true,
"aoColumns": [
//User
{ "mData": function(source, type, val){
var returnString = "Name: " +"" + source.userName + "" +
"
Type: " + "" + source.roleName + "
" +
"Status: " + "" + source.isActive + "";
return returnString;
}},
//Activity
{ "mData": function(source, type, val){
var returnString = "Logins Number: " + source.loginsNum +
"
Last Login: " + source.lastLogin;
return returnString;
}},
//Contact
{ "mData": function(source, type, val){
var returnString = "First Name: " + source.firstName +
"
Last Name: " + source.lastName +
"
Email: " + source.email +
"
Phone: " + source.phone;
return returnString;
}},
//Work
{ "mData": function(source, type, val){
var returnString = "Company: " + source.company +
"
Job title: " + source.job;
return returnString;
}},
//Address
{ "mData": function(source, type, val){
var returnString = "Country: " + source.countryName +
"
City: " + source.city +
"
Street: " + source.street +
"
Postcode: " + source.postcode;
return returnString;
}},
//Options
{ "mData": function(source, type, val){
var editUrl = '@Url.Action("Account", "CMS")' + '?userId=' + source.userID;
var returnString = "Edit" + " / " +
"Delete";
return returnString;
}}
]
}).fnSetFilteringDelay();
and this is the JSON object I return:
return Json(new
{
sEcho = int.Parse(param.sEcho),
iTotalRecords = allUsers.Count(),
iTotalDisplayRecords = filteredResults.Count(),
aaData = result
}, JsonRequestBehavior.AllowGet);
I cannot post a link to the issue, unfortunately.
I use datatables with server side processing and when pressing Next I get a very strange behavior. If "1" is selected in pagination links, it works ok; however, if page "2" is currently selected, pressing next will set iDisplayStart to the value "1010" which corresponds to page 102.
This is my initialization code:
oTable = $('#solutionsTable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bSort": false,
"oLanguage": {
"sSearch": "Search all columns:"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": '@Url.Action("AsyncGetUserData")',
"bDeferRender": true,
"aoColumns": [
//User
{ "mData": function(source, type, val){
var returnString = "Name: " +"" + source.userName + "" +
"
Type: " + "" + source.roleName + "
" +
"Status: " + "" + source.isActive + "";
return returnString;
}},
//Activity
{ "mData": function(source, type, val){
var returnString = "Logins Number: " + source.loginsNum +
"
Last Login: " + source.lastLogin;
return returnString;
}},
//Contact
{ "mData": function(source, type, val){
var returnString = "First Name: " + source.firstName +
"
Last Name: " + source.lastName +
"
Email: " + source.email +
"
Phone: " + source.phone;
return returnString;
}},
//Work
{ "mData": function(source, type, val){
var returnString = "Company: " + source.company +
"
Job title: " + source.job;
return returnString;
}},
//Address
{ "mData": function(source, type, val){
var returnString = "Country: " + source.countryName +
"
City: " + source.city +
"
Street: " + source.street +
"
Postcode: " + source.postcode;
return returnString;
}},
//Options
{ "mData": function(source, type, val){
var editUrl = '@Url.Action("Account", "CMS")' + '?userId=' + source.userID;
var returnString = "Edit" + " / " +
"Delete";
return returnString;
}}
]
}).fnSetFilteringDelay();
and this is the JSON object I return:
return Json(new
{
sEcho = int.Parse(param.sEcho),
iTotalRecords = allUsers.Count(),
iTotalDisplayRecords = filteredResults.Count(),
aaData = result
}, JsonRequestBehavior.AllowGet);
I cannot post a link to the issue, unfortunately.
This discussion has been closed.
Replies
pressing Next the second time makes the info string write : "Showing 0101 to 1,010 of 1,056 entries"; pressing next the third time makes the pagination mechanism jump to page 102, iDisplayStart is set to 1010, the query string is
http://localhost/Archimede.Web/INT/CMS/AsyncGetUserData?sEcho=4&iColumns=6&sColumns=&iDisplayStart=01010&iDisplayLength=10&mDataProp_0=function.
I read a post saying this means server-side process may be returning strings instead of integers. I don't think this is the case, though. This is is what I return in the JSON object:
return Json(new
{
sEcho = param.sEcho,
iTotalRecords = allUsers.Count(),
iTotalDisplayRecords = filteredResults.Count(),
aaData = result
}, JsonRequestBehavior.AllowGet);
Allan