aLengthMenu without 10

aLengthMenu without 10

rdmillerrdmiller Posts: 2Questions: 0Answers: 0
edited January 2011 in Bug reports
[code]jQuery('table')dataTable({
aLengthMenu: [[50,100,300,-1],[50,100,300,'All']]
});[/code]

The length menu looks fine.

But the table shows 10 entries, not 50. So, for example, to get a table with 50 entries I must first change to a different length and then change back.

Replies

  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    I think it's "almost a bug - but not quite" ;-). The reason this is happening is that iDisplayLength ( http://datatables.net/usage/options#iDisplayLength ) which is the draw length to use for the first draw is default 10. It doesn't take the value from aLengthMenu (for flexibility). If you set iDisplayLength to 50 as well it operate as expected.

    Regards,
    Allan
  • rdmillerrdmiller Posts: 2Questions: 0Answers: 0
    Ok, I can live with that.

    That said, since this is something users of aLengthMenu should know about, perhaps the example code entry (or other mentions of aLengthMenu) should refer to it?

    Alternatively, if iDisplayLength defaulted to first entry of aLengthMenu, that would be even nicer, but if you cannot guarantee aLengthMenu handling code happens before iDisplayLength handling code I can understand that.

    But, anyways, I am ok on this issue. Thank you.
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Yup that sounds sensible to me :-). I've just added another code sample for the aLengthMenu ( http://datatables.net/usage/options#aLengthMenu ) documentation which shows this being done with iDisplayLength.

    Thanks!
    Allan
  • icebergiceberg Posts: 14Questions: 0Answers: 0
    I encountered exactly same problem, found same solution independently, have same feeling about "why not let iDisplayLength have a default value as aLengthMenu's first item". Mmm...

    Ray
  • treehousetimtreehousetim Posts: 1Questions: 0Answers: 0
    I'm setting my options like shown below and my table is still defaulting to 10 rows.

    any suggestions?

    [code]$('#fieldgrid').dataTable(
    {
    'bSort': false,
    'bPagination' : false,
    'bJQueryUI': true,
    'aoColumns': [
    { 'sClass': 'col_fieldname' },
    { 'sClass': 'col_fieldtype' },
    { 'sClass': 'col_fieldformtype' },
    { 'sClass': 'col_fieldactions' },
    ],
    'aLengthMenu': [50, 100],
    'iDisplayStart': 50
    });[/code]
  • vifouzvifouz Posts: 4Questions: 0Answers: 0
    the same problem... any suggestions ?
    Thanks
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Yes - give us a link to a demo page showing the problem :-)

    Note that "treehousetim" has pagination disabled in the code above, so obviously setting a page length is going to make no difference.

    Allan
This discussion has been closed.