mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-27 00:54:15 +01:00
Update - example: Add data
option to SSP pipeling
- The piplining example didn't have any method to submit additional data with the Ajax request, other than to modify the library function. - This commit adds a `data` option which provides the same functionality as the `ajax.data` option in DataTables - i.e. it can be an object or function
This commit is contained in:
parent
c5d86ea157
commit
8186f9378c
@ -1 +1 @@
|
|||||||
ef495a01f6e667888e890661e4abf990014a55d6
|
d4aebc0ff333090bf3b1cf840ceeabeb15595203
|
||||||
|
@ -25,8 +25,10 @@
|
|||||||
$.fn.dataTable.pipeline = function ( opts ) {
|
$.fn.dataTable.pipeline = function ( opts ) {
|
||||||
// Configuration options
|
// Configuration options
|
||||||
var conf = $.extend( {
|
var conf = $.extend( {
|
||||||
pages: 5, // number of pages to cache
|
pages: 5, // number of pages to cache
|
||||||
url: '' // script url
|
url: '', // script url
|
||||||
|
data: null // function or object with parameters to send to the server
|
||||||
|
// matching how `ajax.data` works in DataTables
|
||||||
}, opts );
|
}, opts );
|
||||||
|
|
||||||
// Private variables for storing the cache
|
// Private variables for storing the cache
|
||||||
@ -72,6 +74,21 @@ $.fn.dataTable.pipeline = function ( opts ) {
|
|||||||
request.start = requestStart;
|
request.start = requestStart;
|
||||||
request.length = requestLength*conf.pages;
|
request.length = requestLength*conf.pages;
|
||||||
|
|
||||||
|
// Provide the same `data` options as DataTables.
|
||||||
|
if ( $.isFunction ( conf.data ) ) {
|
||||||
|
// As a function it is executed with the data object as an arg
|
||||||
|
// for manipulation. If an object is returned, it is used as the
|
||||||
|
// data object to submit
|
||||||
|
var d = conf.data( request );
|
||||||
|
if ( d ) {
|
||||||
|
$.extend( request, d );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( $.isPlainObject( conf.data ) ) {
|
||||||
|
// As an object, the data given extends the default
|
||||||
|
$.extend( request, conf.data );
|
||||||
|
}
|
||||||
|
|
||||||
settings.jqXHR = $.ajax( {
|
settings.jqXHR = $.ajax( {
|
||||||
"url": conf.url,
|
"url": conf.url,
|
||||||
"data": request,
|
"data": request,
|
||||||
@ -183,8 +200,10 @@ $(document).ready(function() {
|
|||||||
$.fn.dataTable.pipeline = function ( opts ) {
|
$.fn.dataTable.pipeline = function ( opts ) {
|
||||||
// Configuration options
|
// Configuration options
|
||||||
var conf = $.extend( {
|
var conf = $.extend( {
|
||||||
pages: 5, // number of pages to cache
|
pages: 5, // number of pages to cache
|
||||||
url: '' // script url
|
url: '', // script url
|
||||||
|
data: null // function or object with parameters to send to the server
|
||||||
|
// matching how `ajax.data` works in DataTables
|
||||||
}, opts );
|
}, opts );
|
||||||
|
|
||||||
// Private variables for storing the cache
|
// Private variables for storing the cache
|
||||||
@ -230,6 +249,21 @@ $.fn.dataTable.pipeline = function ( opts ) {
|
|||||||
request.start = requestStart;
|
request.start = requestStart;
|
||||||
request.length = requestLength*conf.pages;
|
request.length = requestLength*conf.pages;
|
||||||
|
|
||||||
|
// Provide the same `data` options as DataTables.
|
||||||
|
if ( $.isFunction ( conf.data ) ) {
|
||||||
|
// As a function it is executed with the data object as an arg
|
||||||
|
// for manipulation. If an object is returned, it is used as the
|
||||||
|
// data object to submit
|
||||||
|
var d = conf.data( request );
|
||||||
|
if ( d ) {
|
||||||
|
$.extend( request, d );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( $.isPlainObject( conf.data ) ) {
|
||||||
|
// As an object, the data given extends the default
|
||||||
|
$.extend( request, conf.data );
|
||||||
|
}
|
||||||
|
|
||||||
settings.jqXHR = $.ajax( {
|
settings.jqXHR = $.ajax( {
|
||||||
"url": conf.url,
|
"url": conf.url,
|
||||||
"data": request,
|
"data": request,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user