Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pageResize plugin. Add paging parameter and callback. #359

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions features/pageResize/dataTables.pageResize.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,21 @@
'use strict';


var PageResize = function ( dt, pageResizeManualDelta )
var PageResize = function ( dt, pageResizeManualDelta, pageResizeDrawPagingParameter, pageResizePreDrawCallback )
{
var table = dt.table();

this.s = {
dt: dt,
host: $(table.container()).parent(),
header: $(table.header()),
footer: $(table.footer()),
body: $(table.body()),
container: $(table.container()),
table: $(table.node()),
delta: pageResizeManualDelta
dt: dt,
host: $(table.container()).parent(),
header: $(table.header()),
footer: $(table.footer()),
body: $(table.body()),
container: $(table.container()),
table: $(table.node()),
delta: pageResizeManualDelta,
drawPagingParameter: pageResizeDrawPagingParameter,
preDrawCallback: pageResizePreDrawCallback
};

var host = this.s.host;
Expand All @@ -99,7 +101,9 @@ PageResize.prototype = {
var rowHeight = rows.eq( rows.length > 1 ? 1 : 0 ).height(); // Attempt to use the second row if poss, for top and bottom border
var availableHeight = settings.host.height();
var scrolling = t.header().parentNode !== t.body().parentNode;
var delta = settings.delta;
var delta = settings.delta;
var pagingObject = { paging: settings.drawPagingParameter };
var preDrawCallback = settings.preDrawCallback;

// Subtract the height of the header, footer and the elements
// surrounding the table
Expand All @@ -122,9 +126,10 @@ PageResize.prototype = {

if ( drawRows !== Infinity && drawRows !== -Infinity &&
! isNaN( drawRows ) && drawRows > 0 &&
drawRows !== dt.page.len()
drawRows !== dt.page.len() &&
( !preDrawCallback || preDrawCallback( drawRows, dt.page.len(), pagingObject ) !== false )
) {
dt.page.len( drawRows ).draw();
dt.page.len( drawRows ).draw( pagingObject.paging );
}
},

Expand Down Expand Up @@ -182,7 +187,7 @@ $(document).on( 'init.dt', function ( e, settings ) {
settings.oInit.pageResize ||
$.fn.dataTable.defaults.pageResize )
{
new PageResize( api, settings.oInit.pageResizeManualDelta );
new PageResize( api, settings.oInit.pageResizeManualDelta, settings.oInit.pageResizeDrawPagingParameter, settings.oInit.pageResizePreDrawCallback );
}
} );

Expand Down
7 changes: 7 additions & 0 deletions features/slidingChild/dataTables.slidingChild.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.