Fix: Resizing not working if there are no header or footer. The possible absence of a header and a footer when calculating the height of the container for table rows and rows count is taken into account.

pull/348/head
Alex 7 years ago
parent a0ebc4219e
commit 17e901e928

@ -75,8 +75,12 @@ PageResize.prototype = {
// Subtract the height of the header, footer and the elements
// surrounding the table
if ( ! scrolling ) {
availableHeight -= settings.header.height();
availableHeight -= settings.footer.height();
if ( t.header() ) {
availableHeight -= settings.header.height();
}
if ( t.footer() ) {
availableHeight -= settings.footer.height();
}
}
availableHeight -= offsetTop;
availableHeight -= settings.container.height() - ( offsetTop + settings.table.height() );

@ -1,7 +1 @@
/*!
PageResize for DataTables v1.0.0
2015 SpryMedia Ltd - datatables.net/license
*/
(function(c){var d=function(a){var b=a.table();this.s={dt:a,host:c(b.container()).parent(),header:c(b.header()),footer:c(b.footer()),body:c(b.body()),container:c(b.container()),table:c(b.node())};a=this.s.host;"static"===a.css("position")&&a.css("position","relative");this._attach();this._size()};d.prototype={_size:function(){var a=this.s,b=a.dt,f=b.table(),g=c(a.table).offset().top,d=c("tr",a.body).eq(0).height(),e=a.host.height();f.header().parentNode===f.body().parentNode&&(e-=a.header.height(),
e-=a.footer.height());e=e-g-(a.container.height()-(g+a.table.height()));a=Math.floor(e/d);Infinity!==a&&(-Infinity!==a&&!isNaN(a)&&0<a&&a!==b.page.len())&&b.page.len(a).draw()},_attach:function(){var a=this,b=c("<object/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");b[0].onload=function(){var b=this.contentDocument.body,c=b.offsetHeight;this.contentDocument.defaultView.onresize=function(){var d=b.clientHeight||b.offsetHeight;d!==c&&(c=d,a._size())}};
b.appendTo(this.s.host).attr("data","about:blank")}};c.fn.dataTable.PageResize=d;c.fn.DataTable.PageResize=d;c(document).on("init.dt",function(a,b){if("dt"===a.namespace){var f=new c.fn.dataTable.Api(b);(c(f.table().node()).hasClass("pageResize")||b.oInit.pageResize||c.fn.dataTable.defaults.pageResize)&&new d(f)}})})(jQuery);
(function(t){var e=function(e){var a=e.table();this.s={dt:e,host:t(a.container()).parent(),header:t(a.header()),footer:t(a.footer()),body:t(a.body()),container:t(a.container()),table:t(a.node())};var o=this.s.host;"static"===o.css("position")&&o.css("position","relative"),this._attach(),this._size()};e.prototype={_size:function(){var e=this.s,a=e.dt,o=a.table(),i=t(e.table).offset().top,n=t("tr",e.body).eq(0).height(),s=e.host.height(),h=o.header().parentNode!==o.body().parentNode;h||(o.header()&&(s-=e.header.height()),o.footer()&&(s-=e.footer.height())),s-=i,s-=e.container.height()-(i+e.table.height());var r=Math.floor(s/n);r!==1/0&&r!==-(1/0)&&!isNaN(r)&&r>0&&r!==a.page.len()&&a.page.len(r).draw()},_attach:function(){var e=this,a=t("<object/>").css({position:"absolute",top:0,left:0,height:"100%",width:"100%",zIndex:-1}).attr("type","text/html");a[0].onload=function(){var t=this.contentDocument.body,a=t.offsetHeight;this.contentDocument.defaultView.onresize=function(){var o=t.clientHeight||t.offsetHeight;o!==a&&(a=o,e._size())}},a.appendTo(this.s.host).attr("data","about:blank")}},t.fn.dataTable.PageResize=e,t.fn.DataTable.PageResize=e,t(document).on("init.dt",function(a,o){if("dt"===a.namespace){var i=new t.fn.dataTable.Api(o);(t(i.table().node()).hasClass("pageResize")||o.oInit.pageResize||t.fn.dataTable.defaults.pageResize)&&new e(i)}})})(jQuery);
Loading…
Cancel
Save