Pagination stops after chaging the page size from 10 to 25 please help
Pagination stops after chaging the page size from 10 to 25 please help
rashfmnb
Posts: 1Questions: 1Answers: 0
this is the code for datatable initialization
userTable = $('#UserTable2').dataTable({
"sDom": "<'row'<'col-md-6 col-sm-12'><'col-md-6 col-sm-12'>r>t<'row'<'col-md-4 col-sm-12'i><'col-md-3 col-sm-12'l><'col-md-5 col-sm-12'p>>", //default layout without horizontal scroll(remove this setting to enable horizontal scroll for the table)
"aLengthMenu": [
[10,25, 50, 100],
[10,25, 50, 100] // change per page values here
],
"ajax": "data.json",
"bProcessing": true,
"bServerSide": true,
//"paging": true,
//"bDefaultContent": "-",
"order": [[UserSortCol, UserSortDir]],
"sAjaxSource": "/Security/AjaxHandlerUser",
"iDisplayLength": 10,
"bPaginate": true,
"fnInitComplete": function (oSettings, json) {
//debugger;
//alert('DataTables has finished its initialisation.' + json.status);
},
"sPaginationType": "bootstrap_full_number",
"fnServerData": function (sSource, aoData, fnCallback) {
//debugger;
aoData.push(
{ "name": "SearchBy", "value": $("#SearchStr").val() },
{ "name": "UserRoleId", "value": $("#dlluserRoles2").val() },
{ "name": "ActiveStr", "value": $("#activedll").val() },
{ "name": "PrimaryStr", "value": $("#primarydll").val() },
{
"name": "radomNumber", "value": Math.random()
}
);
$.getJSON(sSource, aoData, function (json) {
//debugger;
fnCallback(json);
jQuery("#SearchStr").focus();
});
},
"fnDrawCallback": function () {
//restorecheckBoxes(this);
disableEditDeleteLinks();
},
"oLanguage": {
"sInfo": 'Showing _START_ to _END_ of _TOTAL_ Records',
"sInfoEmpty": 'No records',
"sEmptyTable": "No records found",
//"sProcessing": '<img src="/Images/ajax-loader.gif" />',
"sProcessing": ' <img src="/Content/themes/assets/img/ajax-loading.gif" alt="Loading..." height="45" width="45">',
"sLengthMenu": "_MENU_ records",
"oPaginate": {
"sPrevious": "Prev",
"sNext": "Next"
}
},
"aoColumns": [
//action column
{
"sName": "UserId",
"sWidth": "12%",
"sClass": "leftClass",
"bSearchable": false,
"bSortable": false,
"mRender": function (data, type, row) {
return '<a class="ActionLink EditSecurityClass" title="Edit" href="#basic_modalPopup" data-toggle="modal" data-keyboard="false" data-id="' + row[6] + '" data-backdrop="static"><i class="fa fa-pencil-square-o fasize"></i></a>'
+ '<span class="faseparator">| </span><a title="Delete" href="#" onclick="return showDeleteModal(' + row[6] + ')" data-toggle="modal" data-keyboard="false" data-id="' + row[6] + '" data-backdrop="static" class="deleteUser DeleteSecurityClass"><i class="fa fa-trash fasize"></i></a>';
}
},
//Login Name
{
"sName": "LoginName",
"sWidth": "9%",
"bSearchable": false,
"bSortable": true,
"mRender": function (data, type, row) {
//return '<a href=\"#CustomerModal\" class=\"EditSecurityClass \" role=\"button\" data-backdrop="static" data-keyboard="false" ' + 'onclick=editClicked(\"' + row[12] + '\"); data-toggle=\"modal\" >' + row[2] + '</a>';
return '<a class="ActionLink EditSecurityClass" title="Edit" onclick="OpenModalPopupForEdit('+row[6]+')" data-toggle="modal" data-keyboard="false" data-id="' + row[6] + '" data-backdrop="static">' + row[2] + '</a>';
}
},
//User Name
{
"sName": "UserName",
"sWidth": "13%",
"mRender": function (data, type, row) {
//return '<a href=\"#CustomerModal\" class=\"EditSecurityClass\" role=\"button\" data-backdrop="static" data-keyboard="false" ' + 'onclick=editClicked(\"' + row[12] + '\"); data-toggle=\"modal\" >' + row[3] + '</a>';
return '<a class="ActionLink EditSecurityClass" title="Edit" onclick="OpenModalPopupForEdit(' + row[6] + ')" data-toggle="modal" data-keyboard="false" data-id="' + row[6] + '" data-backdrop="static">' + row[1] + '</a>';
}
},
{
"sName": "UserRoleName",
"sWidth": "13%",
"bSortable": true,
},
{
"sName": "IsActive",
"sWidth": "6%",
"sClass": "centerClass",
"mRender": function (data, type, row) {
if (row[4] === 'true')
return "<i class=\"fa fa-check\" style=\"margin-left:0px;\"></i>";
else
return "<i class=\"fa fa-times\" style=\"margin-left:0px;\"></i>";
}
},
{
"sName": "IsPrimary",
"sWidth": "6%",
"sClass": "centerClass",
"mRender": function (data, type, row) {
if (row[5] === 'true')
return "<i class=\"fa fa-check\" style=\"margin-left:0px;\"></i>";
else
return "<i class=\"fa fa-times\" style=\"margin-left:0px;\"></i>";
}
}
]
});
and this is the reponse i am getting from server this is in the case when displaylength is 10 on this paging and everything is working fine but as soon as i change displaylength to 25 it stops working
{
"sEcho": "1",
"iTotalRecords": 103,
"iTotalDisplayRecords": 103,
"aaData": [["2147",... // array of length 10 if displaylength is 10 else 25 if display lenght is 25
"recordsFiltered": 103,
"recordsTotal": 103
}
This discussion has been closed.