From 38fa0524444d278802629211092f6f6cac5adb6b Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Wed, 30 Jan 2013 07:42:15 +0000 Subject: [PATCH] api - fnPagingInfo.js plug-in didn't correctly handle -1 page length --- api/fnPagingInfo.js | 20 ++++++++++--------- integration/bootstrap/dataTables.bootstrap.js | 6 ++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/api/fnPagingInfo.js b/api/fnPagingInfo.js index 56e3bb5..0a2d4bf 100644 --- a/api/fnPagingInfo.js +++ b/api/fnPagingInfo.js @@ -18,13 +18,15 @@ $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) { - return { - "iStart": oSettings._iDisplayStart, - "iEnd": oSettings.fnDisplayEnd(), - "iLength": oSettings._iDisplayLength, - "iTotal": oSettings.fnRecordsTotal(), - "iFilteredTotal": oSettings.fnRecordsDisplay(), - "iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), - "iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) - }; + return { + "iStart": oSettings._iDisplayStart, + "iEnd": oSettings.fnDisplayEnd(), + "iLength": oSettings._iDisplayLength, + "iTotal": oSettings.fnRecordsTotal(), + "iFilteredTotal": oSettings.fnRecordsDisplay(), + "iPage": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), + "iTotalPages": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) + }; }; diff --git a/integration/bootstrap/dataTables.bootstrap.js b/integration/bootstrap/dataTables.bootstrap.js index 4a3caf5..7c552e0 100644 --- a/integration/bootstrap/dataTables.bootstrap.js +++ b/integration/bootstrap/dataTables.bootstrap.js @@ -23,8 +23,10 @@ $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) "iLength": oSettings._iDisplayLength, "iTotal": oSettings.fnRecordsTotal(), "iFilteredTotal": oSettings.fnRecordsDisplay(), - "iPage": Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), - "iTotalPages": Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) + "iPage": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), + "iTotalPages": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) }; };