1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-20 18:54:15 +01:00

Update - examples: Pipeline example now registers a clearPipeline()

method
This commit is contained in:
Allan Jardine 2014-03-04 08:52:37 +00:00
parent 10634dd733
commit 876eb29b9b
2 changed files with 29 additions and 3 deletions

View File

@ -1 +1 @@
747b47fa62dea0dbf7261943a63d68cf00f5ab3a
dbd08731ff5017c85be08d79d7c764bcea02c64a

View File

@ -44,7 +44,12 @@ $.fn.dataTable.pipeline = function ( opts ) {
var requestLength = request.length;
var requestEnd = requestStart + requestLength;
if ( cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper ) {
if ( settings.clearCache ) {
// API requested that the cache be cleared
ajax = true;
settings.clearCache = false;
}
else if ( cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper ) {
// outside cached data - need to make a request
ajax = true;
}
@ -119,6 +124,14 @@ $.fn.dataTable.pipeline = function ( opts ) {
}
};
// Register an API method that will empty the pipelined data, forcing an Ajax
// fetch on the next draw (i.e. `table.clearPipeline().draw()`)
$.fn.dataTable.Api.register( 'clearPipeline()', function () {
return this.iterator( 'table', function ( settings ) {
settings.clearCache = true;
} );
} );
//
// DataTables initialisation
@ -221,7 +234,12 @@ $.fn.dataTable.pipeline = function ( opts ) {
var requestLength = request.length;
var requestEnd = requestStart + requestLength;
if ( cacheLower &lt; 0 || requestStart &lt; cacheLower || requestEnd &gt; cacheUpper ) {
if ( settings.clearCache ) {
// API requested that the cache be cleared
ajax = true;
settings.clearCache = false;
}
else if ( cacheLower &lt; 0 || requestStart &lt; cacheLower || requestEnd &gt; cacheUpper ) {
// outside cached data - need to make a request
ajax = true;
}
@ -296,6 +314,14 @@ $.fn.dataTable.pipeline = function ( opts ) {
}
};
// Register an API method that will empty the pipelined data, forcing an Ajax
// fetch on the next draw (i.e. `table.clearPipeline().draw()`)
$.fn.dataTable.Api.register( 'clearPipeline()', function () {
return this.iterator( 'table', function ( settings ) {
settings.clearCache = true;
} );
} );
//
// DataTables initialisation