From afeacc71a58c5d9e234a2c9898ede28db1020049 Mon Sep 17 00:00:00 2001 From: Alghazali Abdulrahman <40702435+DrAlghazali@users.noreply.github.com> Date: Thu, 26 Jan 2023 11:44:39 +0300 Subject: [PATCH] lengthMenu --- js/core/core.length.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/core/core.length.js b/js/core/core.length.js index 04785eaa1..4cb393b79 100644 --- a/js/core/core.length.js +++ b/js/core/core.length.js @@ -1,8 +1,15 @@ function _fnLengthChange ( settings, val ) { - var len = parseInt( val, 10 ); - settings._iDisplayLength = len; + // val: is coming directily from the dom + var len = parseInt(val, 10), + //Add a way to prevent end user from changing the lengthMenu value in the dom + menu = settings.aLengthMenu, + d2 = Array.isArray(menu[0]), + originalLengths = d2 ? menu[0] : menu; + // if the value is not in the original values when initiating the data table then choose the min value + // this will be of use when using ssp whith large tables where you want to make sure that there is a LIMIT restriction + settings._iDisplayLength = originalLengths.includes(len) ? len : Math.min(...originalLengths); _fnLengthOverflow( settings );