diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 511f2f0c..6eff7960 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -6180,6 +6180,13 @@ _fnLanguageCompat( oInit.oLanguage ); } + // If the length menu is given, but the init display length is not, use the length menu + if ( oInit.aLengthMenu && ! oInit.iDisplayLength ) + { + oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ? + oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0]; + } + oInit = _fnExtend( $.extend(true, {}, DataTable.defaults), oInit ); // Map the initialisation options onto the settings object @@ -7635,6 +7642,9 @@ * option and the value, or a 2D array which will use the array in the first * position as the value, and the array in the second position as the * displayed options (useful for language strings such as 'All'). + * + * Note that the `displayLength` property will be automatically set to the + * first value given in this array, unless `displayLength` is also provided. * @type array * @default [ 10, 25, 50, 100 ] * @@ -7647,17 +7657,6 @@ * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]] * } ); * } ); - * - * @example - * // Setting the default display length as well as length menu - * // This is likely to be wanted if you remove the '10' option which - * // is the displayLength default. - * $(document).ready( function() { - * $('#example').dataTable( { - * "displayLength": 25, - * "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]] - * } ); - * } ); */ "aLengthMenu": [ 10, 25, 50, 100 ], diff --git a/media/src/core/core.constructor.js b/media/src/core/core.constructor.js index 0aea5a6b..80a8b419 100644 --- a/media/src/core/core.constructor.js +++ b/media/src/core/core.constructor.js @@ -88,6 +88,13 @@ if ( oInit.oLanguage ) _fnLanguageCompat( oInit.oLanguage ); } +// If the length menu is given, but the init display length is not, use the length menu +if ( oInit.aLengthMenu && ! oInit.iDisplayLength ) +{ + oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ? + oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0]; +} + oInit = _fnExtend( $.extend(true, {}, DataTable.defaults), oInit ); // Map the initialisation options onto the settings object diff --git a/media/src/model/model.defaults.js b/media/src/model/model.defaults.js index 437b23b3..dd4de19b 100644 --- a/media/src/model/model.defaults.js +++ b/media/src/model/model.defaults.js @@ -143,6 +143,9 @@ DataTable.defaults = { * option and the value, or a 2D array which will use the array in the first * position as the value, and the array in the second position as the * displayed options (useful for language strings such as 'All'). + * + * Note that the `displayLength` property will be automatically set to the + * first value given in this array, unless `displayLength` is also provided. * @type array * @default [ 10, 25, 50, 100 ] * @@ -155,17 +158,6 @@ DataTable.defaults = { * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]] * } ); * } ); - * - * @example - * // Setting the default display length as well as length menu - * // This is likely to be wanted if you remove the '10' option which - * // is the displayLength default. - * $(document).ready( function() { - * $('#example').dataTable( { - * "displayLength": 25, - * "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]] - * } ); - * } ); */ "aLengthMenu": [ 10, 25, 50, 100 ],