Custom Length Issue
Custom Length Issue
serbstream
Posts: 5Questions: 0Answers: 0
Hello,
I have impletemented a custom length drop down for the end user. Allowing then to submit a default length that they want displayed as well as allowing them to change it at runtime. I used the oLanguage method to accomplish this. However it seems when you do this, the next button no longer functions correctly. It seems to send the default submitted length with a leading zero. Here is the code i used below. The first, last, and previous buttons seem to work fine. Is there anything i can do to work around this or am i doing sometihng incorrectly. Thanks for the help.
[code]
function loadTables(table, column, direction) {
//
//
//
//
var thispage = $('body').data('thisPage');
var clientresults = $('body').data('clientresults');
var otable;
otable = $(table).dataTable({
"bPaginate": true,
"sPaginationType": "full_numbers", //two_button
"bLengthChange": true,
"bFilter": false,
"bSort": true,
"bInfo": true,
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": thispage + "?action=buildevents",
"fnServerData": function (sSource, aoData, fnCallback) {
//var filter = $(table + '_filter').val();
//aoData.push({ "name": "filter", "value": "" + filter + "" });
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback,
"cache": false
});
},
//"fnDrawCallback": opencloseRow,
"aoColumns": [{ "bVisible": false }, null, null, { "bSearchable": false, "bVisible": true }, { "bSearchable": false, "bVisible": true }, { "bSearchable": false, "bVisible": true }, { "bSearchable": false, "bVisible": true}],
"aaSorting": [[column, direction]],
"iDisplayLength": clientresults,
"oLanguage": {
"sLengthMenu": 'Show ' +
'' + clientresults + '' +
'10' +
'20' +
'30' +
'40' +
'50' +
' entries'
}
});
[/code]
I have impletemented a custom length drop down for the end user. Allowing then to submit a default length that they want displayed as well as allowing them to change it at runtime. I used the oLanguage method to accomplish this. However it seems when you do this, the next button no longer functions correctly. It seems to send the default submitted length with a leading zero. Here is the code i used below. The first, last, and previous buttons seem to work fine. Is there anything i can do to work around this or am i doing sometihng incorrectly. Thanks for the help.
[code]
function loadTables(table, column, direction) {
//
//
//
//
var thispage = $('body').data('thisPage');
var clientresults = $('body').data('clientresults');
var otable;
otable = $(table).dataTable({
"bPaginate": true,
"sPaginationType": "full_numbers", //two_button
"bLengthChange": true,
"bFilter": false,
"bSort": true,
"bInfo": true,
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": thispage + "?action=buildevents",
"fnServerData": function (sSource, aoData, fnCallback) {
//var filter = $(table + '_filter').val();
//aoData.push({ "name": "filter", "value": "" + filter + "" });
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback,
"cache": false
});
},
//"fnDrawCallback": opencloseRow,
"aoColumns": [{ "bVisible": false }, null, null, { "bSearchable": false, "bVisible": true }, { "bSearchable": false, "bVisible": true }, { "bSearchable": false, "bVisible": true }, { "bSearchable": false, "bVisible": true}],
"aaSorting": [[column, direction]],
"iDisplayLength": clientresults,
"oLanguage": {
"sLengthMenu": 'Show ' +
'' + clientresults + '' +
'10' +
'20' +
'30' +
'40' +
'50' +
' entries'
}
});
[/code]
This discussion has been closed.
Replies
I might be misunderstanding a little bit, but "clientresults" is the value that is submitted right? And you say it has a leading zero? If that leading zero is removed, does it start working again? I've just tried the following code and it seems to work fine for me:
[code]
/* Language and options change */
$(document).ready(function() {
var whatever = 25;
$('#example').dataTable( {
"sPaginationType": "full_numbers",
"iDisplayLength": whatever,
"oLanguage": {
"sLengthMenu": 'Display '+
'10'+
''+whatever+''+
'20'+
'30'+
'40'+
'50'+
'All'+
' records'
}
} );
} );
[/code]
Perhaps if this post doesn't help resolve the issue you could post a link to a page showing the problem.
Regards,
Allan
here is a test page
http://www.djintelligence.com/dev/test.asp
Thank you very much for the help!
I wonder if this is a type casting issue. I see that you are using $('body').data('clientresults') to assign "clientresults". I strongly suspect that this will be returning a string rather than in integer - which is what iDisplayLength is expecting. Try doing:
[code]
var clientresults = parseInt( $('body').data('clientresults') );
[/code]
and see if that helps. Damn these loosely typed languages ;-)
Regards,
Allan