Custom Length Issue

Custom Length Issue

serbstreamserbstream Posts: 5Questions: 0Answers: 0
edited November 2009 in General
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]

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi serbstream,

    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
  • serbstreamserbstream Posts: 5Questions: 0Answers: 0
    Allan thank you very much for your quick response. If you change the length and change it back to the dynamic value it seems to work fine then. However if you click next on initial load it adds the leading zero on post. I am removing the leading zero in my code however it seems to not like it in the javascript. It displays this as the information "Showing 021 to 022 of 6 entries" and then doesn't change, unless you hit another button like first or last or an actual page number

    here is a test page
    http://www.djintelligence.com/dev/test.asp

    Thank you very much for the help!
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi serbstream,

    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
  • serbstreamserbstream Posts: 5Questions: 0Answers: 0
    haha! that was Awesome. thanks for you help and have a happy Thanksgiving!
This discussion has been closed.