1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-03-15 16:29:16 +01:00

New: Default Ajax source property updated to be data

- In keeping with the camelCase name changes for DataTables 1.10, the
  default Ajax data source object property name has been updated from
  `aaData` to just `data`. Note that this is a fulyl backwards
  compatible change - if aaData is present in the data, it will be used.
This commit is contained in:
Allan Jardine 2013-10-10 17:46:26 +01:00
parent fe1a5a630a
commit 3795134856
2 changed files with 27 additions and 22 deletions

View File

@ -1 +1 @@
f11c3ae860dfc41e4a4d9eda1d8af7aa7f5886d3
9fd084bdae8fa642638c88f15592e3322548c328

View File

@ -2165,13 +2165,18 @@
*/
function _fnAjaxDataSrc ( oSettings, json )
{
// @todo data and callback to aaData
var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
oSettings.ajax.dataSrc :
oSettings.sAjaxDataProp; // Compatibility with 1.9-.
// Compatibility with 1.9-. In order to read from aaData, check if the
// default has been changed, if not, check for aaData
if ( dataSrc === 'data' ) {
return json.aaData || json[dataSrc];
}
return dataSrc !== "" ?
_fnGetObjectDataFn( dataSrc )(json) :
_fnGetObjectDataFn( dataSrc )( json ) :
json;
}
@ -9023,15 +9028,16 @@
* not return anything from the function. This supersedes `fnServerParams`
* from DataTables 1.9-.
*
* * `dataSrc` - By default DataTables will look for the property 'aaData'
* when obtaining data from an Ajax source or for server-side processing -
* this parameter allows that property to be changed. You can use
* Javascript dotted object notation to get a data source for multiple
* levels of nesting, or it my be used as a function. As a function it
* takes a single parameter, the JSON returned from the server, which can
* be manipulated as required, with the returned value being that used by
* DataTables as the data source for the table. This supersedes
* `sAjaxDataProp` from DataTables 1.9-.
* * `dataSrc` - By default DataTables will look for the property `data` (or
* `aaData` for compatibility with DataTables 1.9-) when obtaining data
* from an Ajax source or for server-side processing - this parameter
* allows that property to be changed. You can use Javascript dotted
* object notation to get a data source for multiple levels of nesting, or
* it my be used as a function. As a function it takes a single parameter,
* the JSON returned from the server, which can be manipulated as
* required, with the returned value being that used by DataTables as the
* data source for the table. This supersedes `sAjaxDataProp` from
* DataTables 1.9-.
*
* * `success` - Should not be overridden it is used internally in
* DataTables. To manipulate / transform the data returned by the server
@ -9065,14 +9071,14 @@
*
* @example
* // Get JSON data from a file via Ajax.
* // Note DataTables expects data in the form `{ aaData: [ ...data... ] }` by default).
* // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
* $('#example').dataTable( {
* "ajax": "data.json"
* } );
*
* @example
* // Get JSON data from a file via Ajax, using `dataSrc` to change
* // `aaData` to `tableData` (i.e. `{ aaData: [ ...data... ] }`)
* // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
* $('#example').dataTable( {
* "ajax": {
* "url": "data.json",
@ -10824,12 +10830,13 @@
* __Deprecated__ The functionality provided by this parameter has now been
* superseded by that provided through `ajax`, which should be used instead.
*
* By default DataTables will look for the property 'aaData' when obtaining
* data from an Ajax source or for server-side processing - this parameter
* allows that property to be changed. You can use Javascript dotted object
* notation to get a data source for multiple levels of nesting.
* By default DataTables will look for the property `data` (or `aaData` for
* compatibility with DataTables 1.9-) when obtaining data from an Ajax
* source or for server-side processing - this parameter allows that
* property to be changed. You can use Javascript dotted object notation to
* get a data source for multiple levels of nesting.
* @type string
* @default aaData
* @default data
*
* @dtopt Options
* @dtopt Server-side
@ -10837,7 +10844,7 @@
*
* @deprecated 1.10. Please use `ajax` for this functionality now.
*/
"sAjaxDataProp": "aaData",
"sAjaxDataProp": "data",
/**
@ -10847,8 +10854,6 @@
* You can instruct DataTables to load data from an external
* source using this parameter (use aData if you want to pass data in you
* already have). Simply provide a url a JSON object can be obtained from.
* This object must include the parameter `aaData` which is the data source
* for the table.
* @type string
* @default null
*