Possible bug in aLengthMenu problem on the "All" option.
Possible bug in aLengthMenu problem on the "All" option.
dinobernal
Posts: 6Questions: 0Answers: 0
There are no problems when display 10, 25 and 50 records.
But when choosing -1 or All, I see two problems/issues.
1. At the bottom, it will display "Showing 1 to -1 of 56 entries".
2. 50 records out of 56 are displayed and the First/Previous/Next/Last buttons are grayed out.
I'm using version 1.7.0 and below is the code.
jQuery().ready(function() {
jQuery('.appliance-list').dataTable({
aaSorting: [[ 3, "asc" ]],
aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
bProcessing: true,
bServerSide: true,
sAjaxSource: '%getUrl',
bJQueryUI: true,
sPaginationType: 'full_numbers',
iDisplayStart: 0,
iDisplayLength: 50,
bRetrieve: true,
bAutoWidth: false,
aoColumns: [
{ sWidth: '10px', bSearchable: false },
{ bSearchable: false, bVisible: false },
null,
null,
{ sWidth: '50px' },
{ sWidth: '50px' },
{ sWidth: '150px' },
{ sWidth: '50px' },
{ sWidth: '50px' },
{ sWidth: '50px' },
{ sWidth: '50px' },
{ sWidth: '70px', bSearchable: false, bSortable: false }
],
fnRowCallback: function( nRow, aData, iDisplayIndex ) {
jQuery('td:eq(0)', nRow).html('');
if ( aData[7] == 1) {
jQuery('td:eq(6)', nRow).html( '' );
} else {
jQuery('td:eq(6)', nRow).html( '' );
}
if ( aData[8] == 1) {
jQuery('td:eq(7)', nRow).html( '' );
} else {
jQuery('td:eq(7)', nRow).html( '' );
}
if ( aData[9] == 1) {
jQuery('td:eq(8)', nRow).html( '' );
} else {
jQuery('td:eq(8)', nRow).html( '' );
}
jQuery('td:eq(10)', nRow).addClass('actions');
return nRow;
},
fnServerData: function ( url, data, callback ) {
jQuery.ajax({
"url": url,
"data": data,
"success": callback,
"dataType": "json",
"cache": false,
"error": function (xhr) {
if (!xhr || xhr.status != 401) {
alert( "DataTables warning: JSON data from server failed to load or be parsed. "+
"This is most likely to be caused by a JSON formatting error." );
} else {
alert('Your session expired !');
window.location.href = '%loginUrl';
}
}
});
}
});
// remove icon click
jQuery('.appliance-list a.remove').live('click', function() {
return confirm('%confirmText');
});
// all checkbox support
jQuery('input[type="checkbox"][id="all"]').click(function(ev) {
var t = jQuery(this);
if (t.attr('checked')) {
jQuery('input[type="checkbox"][id!="all"]').attr('checked', 'checked');
} else {
jQuery('input[type="checkbox"][id!="all"]').removeAttr('checked');
}
ev.stopPropagation();
});
jQuery('a#batch').click(function() {
var list = jQuery('input[type="checkbox"][id!="all"]:checked');
if (list.length) {
var applianceList = [];
list.each(function(idx, item) {
applianceList.push(item.name);
});
jQuery.post('%batchIdUrl', {applianceList: applianceList}, function(data, status, xhr) {
if (data.message) {
alert(data.message);
} else if (data.setId) {
redirect('%redirectUrl' + '/index/set_id/' + data.setId);
} else {
alert('An error occured while getting set id');
}
}, 'json');
} else {
alert('%selected');
}
return false;
});
});
But when choosing -1 or All, I see two problems/issues.
1. At the bottom, it will display "Showing 1 to -1 of 56 entries".
2. 50 records out of 56 are displayed and the First/Previous/Next/Last buttons are grayed out.
I'm using version 1.7.0 and below is the code.
jQuery().ready(function() {
jQuery('.appliance-list').dataTable({
aaSorting: [[ 3, "asc" ]],
aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
bProcessing: true,
bServerSide: true,
sAjaxSource: '%getUrl',
bJQueryUI: true,
sPaginationType: 'full_numbers',
iDisplayStart: 0,
iDisplayLength: 50,
bRetrieve: true,
bAutoWidth: false,
aoColumns: [
{ sWidth: '10px', bSearchable: false },
{ bSearchable: false, bVisible: false },
null,
null,
{ sWidth: '50px' },
{ sWidth: '50px' },
{ sWidth: '150px' },
{ sWidth: '50px' },
{ sWidth: '50px' },
{ sWidth: '50px' },
{ sWidth: '50px' },
{ sWidth: '70px', bSearchable: false, bSortable: false }
],
fnRowCallback: function( nRow, aData, iDisplayIndex ) {
jQuery('td:eq(0)', nRow).html('');
if ( aData[7] == 1) {
jQuery('td:eq(6)', nRow).html( '' );
} else {
jQuery('td:eq(6)', nRow).html( '' );
}
if ( aData[8] == 1) {
jQuery('td:eq(7)', nRow).html( '' );
} else {
jQuery('td:eq(7)', nRow).html( '' );
}
if ( aData[9] == 1) {
jQuery('td:eq(8)', nRow).html( '' );
} else {
jQuery('td:eq(8)', nRow).html( '' );
}
jQuery('td:eq(10)', nRow).addClass('actions');
return nRow;
},
fnServerData: function ( url, data, callback ) {
jQuery.ajax({
"url": url,
"data": data,
"success": callback,
"dataType": "json",
"cache": false,
"error": function (xhr) {
if (!xhr || xhr.status != 401) {
alert( "DataTables warning: JSON data from server failed to load or be parsed. "+
"This is most likely to be caused by a JSON formatting error." );
} else {
alert('Your session expired !');
window.location.href = '%loginUrl';
}
}
});
}
});
// remove icon click
jQuery('.appliance-list a.remove').live('click', function() {
return confirm('%confirmText');
});
// all checkbox support
jQuery('input[type="checkbox"][id="all"]').click(function(ev) {
var t = jQuery(this);
if (t.attr('checked')) {
jQuery('input[type="checkbox"][id!="all"]').attr('checked', 'checked');
} else {
jQuery('input[type="checkbox"][id!="all"]').removeAttr('checked');
}
ev.stopPropagation();
});
jQuery('a#batch').click(function() {
var list = jQuery('input[type="checkbox"][id!="all"]:checked');
if (list.length) {
var applianceList = [];
list.each(function(idx, item) {
applianceList.push(item.name);
});
jQuery.post('%batchIdUrl', {applianceList: applianceList}, function(data, status, xhr) {
if (data.message) {
alert(data.message);
} else if (data.setId) {
redirect('%redirectUrl' + '/index/set_id/' + data.setId);
} else {
alert('An error occured while getting set id');
}
}, 'json');
} else {
alert('%selected');
}
return false;
});
});
This discussion has been closed.
Replies
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "../examples_support/server_processing.php",
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
iDisplayStart: 0,
iDisplayLength: 50
} );
} );
[/code]
and it seems to work as expect for me. I don't think there has been a bug found/fixed in aLengthMenu since 1.7.0 but I could be wrong - it would be worth upgrading to 1.7.6 and seeing if the situation changes. Failing that, can you give us a link please? I'm wonder want gets sent to / from the server on the -1 request.
Allan
To answer your question with regards to the link, I can provide a link because the application is internal and not available online.
Can I request for an example here in the DataTables example that shows the "All" option?
It shows "Showing 1 to -1 of 56 entries".
Allan