From e92582b45af59b4d95eca3165b76373dfc1172fe Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Thu, 30 Oct 2014 15:15:20 +0000 Subject: [PATCH] Fix: Page length change will now attempt to keep the start point on the current page, but will shift that row's position away from the start point, so that the paging is always consistent in its display. Without this changing the page length could result in landing on page "1.4" (or some other partial page) that you could never get to with just paging alone. That is no longer possible in DataTables. This is something that has been in DataTables since the version first vresion and was contentious at that point so while this is a minor code change, for me it is quite a big change! I feel that this is the correct operation now, although it does result in rows being moved around where they might not be needed to if partial pages could be used. --- .datatables-commit-sync | 2 +- media/js/jquery.dataTables.js | 5 ++++- media/js/jquery.dataTables.min.js | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.datatables-commit-sync b/.datatables-commit-sync index a470270b..e964c81b 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -417acf5b442bfcafed313b39564f012a5128275e +eaab86e69bff4097fc40e67eab5be8a62aeb1c0f diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 5c29ba55..4802f8ac 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -5167,11 +5167,14 @@ len = settings._iDisplayLength; /* If we have space to show extra rows (backing up from the end point - then do so */ - if (start >= end) + if ( start >= end ) { start = end - len; } + // Keep the start record on the current page + start -= (start % len); + if ( len === -1 || start < 0 ) { start = 0; diff --git a/media/js/jquery.dataTables.min.js b/media/js/jquery.dataTables.min.js index 818396e4..0562647f 100644 --- a/media/js/jquery.dataTables.min.js +++ b/media/js/jquery.dataTables.min.js @@ -69,8 +69,8 @@ d[0][0]==b?(b=h(d[0]),d.length=1,d[0][1]=f[b],d[0]._idx=b):(d.length=0,d.push([b [a,d]),-1===g.inArray(!1,b)&&(b=a.iStateDuration,!(0=e.length?[0,c[1]]:c)});g.extend(a.oPreviousSearch,Ab(d.search));b=0;for(c=d.columns.length;b=c&&(b=c-e);if(-1===e||0>b)b=0;a._iDisplayStart=b}function Pa(a,b){var c=a.renderer,e=p.ext.renderer[b];return g.isPlainObject(c)&&c[b]?e[c[b]]||e._:"string"===typeof c?e[c]||e._:e._}function A(a){return a.oFeatures.bServerSide?"ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function Wa(a,b){var c= -[],c=Mb.numbers_length,e=Math.floor(c/2);b<=c?c=U(0,b):a<=e?(c=U(0,c-2),c.push("ellipsis"),c.push(b-1)):(a>=b-1-e?c=U(b-(c-2),b):(c=U(a-1,a+2),c.push("ellipsis"),c.push(b-1)),c.splice(0,0,"ellipsis"),c.splice(0,0,0));c.DT_el="span";return c}function db(a){g.each({num:function(b){return Aa(b,a)},"num-fmt":function(b){return Aa(b,a,Xa)},"html-num":function(b){return Aa(b,a,Ba)},"html-num-fmt":function(b){return Aa(b,a,Ba,Xa)}},function(b,c){w.type.order[b+a+"-pre"]=c;b.match(/^html\-/)&&(w.type.search[b+ +[];b&&(d=g.map(a[b].slice().reverse(),function(b){return b.fn.apply(a.oInstance,e)}));null!==c&&g(a.nTable).trigger(c+".dt",e);return d}function Sa(a){var b=a._iDisplayStart,c=a.fnDisplayEnd(),e=a._iDisplayLength;b>=c&&(b=c-e);b-=b%e;if(-1===e||0>b)b=0;a._iDisplayStart=b}function Pa(a,b){var c=a.renderer,e=p.ext.renderer[b];return g.isPlainObject(c)&&c[b]?e[c[b]]||e._:"string"===typeof c?e[c]||e._:e._}function A(a){return a.oFeatures.bServerSide?"ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function Wa(a, +b){var c=[],c=Mb.numbers_length,e=Math.floor(c/2);b<=c?c=U(0,b):a<=e?(c=U(0,c-2),c.push("ellipsis"),c.push(b-1)):(a>=b-1-e?c=U(b-(c-2),b):(c=U(a-1,a+2),c.push("ellipsis"),c.push(b-1)),c.splice(0,0,"ellipsis"),c.splice(0,0,0));c.DT_el="span";return c}function db(a){g.each({num:function(b){return Aa(b,a)},"num-fmt":function(b){return Aa(b,a,Xa)},"html-num":function(b){return Aa(b,a,Ba)},"html-num-fmt":function(b){return Aa(b,a,Ba,Xa)}},function(b,c){w.type.order[b+a+"-pre"]=c;b.match(/^html\-/)&&(w.type.search[b+ a]=w.type.search.html)})}function Nb(a){return function(){var b=[za(this[p.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return p.ext.internal[a].apply(this,b)}}var p,w,q,r,t,Ya={},Ob=/[\r\n]/g,Ba=/<.*?>/g,$b=/^[\w\+\-]/,ac=/[\w\+\-]$/,Xb=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^|\\-)","g"),Xa=/[',$\u00a3\u20ac\u00a5%\u2009\u202F]/g,H=function(a){return!a||!0===a||"-"===a?!0:!1},Pb=function(a){var b=parseInt(a,10);return!isNaN(b)&&isFinite(a)?b:null},Qb= function(a,b){Ya[b]||(Ya[b]=RegExp(va(b),"g"));return"string"===typeof a&&"."!==b?a.replace(/\./g,"").replace(Ya[b],"."):a},Za=function(a,b,c){var e="string"===typeof a;b&&e&&(a=Qb(a,b));c&&e&&(a=a.replace(Xa,""));return H(a)||!isNaN(parseFloat(a))&&isFinite(a)},Rb=function(a,b,c){return H(a)?!0:!(H(a)||"string"===typeof a)?null:Za(a.replace(Ba,""),b,c)?!0:null},C=function(a,b,c){var e=[],d=0,f=a.length;if(c!==l)for(;d")[0],Yb=wa.textContent!==l,Zb=/<.*?>/g;p=function(a){this.$=