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

Fix: When fnUpdate is called with a column index given, assume that the update is for an individual cell (which the API call has specified, so this is the correct thing to do). This also lets us tidy up some of the code in fnUpate, partiuclarly when regarding deeply nested options.

This commit is contained in:
Allan Jardine 2012-06-26 17:09:03 +01:00
parent a022e2f736
commit 56b0d11c96
2 changed files with 4 additions and 12 deletions

View File

@ -5993,30 +5993,26 @@
var iRow = (typeof mRow === 'object') ?
_fnNodeToDataIndex(oSettings, mRow) : mRow;
if ( oSettings.__fnUpdateDeep === undefined && $.isArray(mData) && typeof mData === 'object' )
if ( $.isArray(mData) && iColumn === undefined )
{
/* Array update - update the whole row */
oSettings.aoData[iRow]._aData = mData.slice();
/* Flag to the function that we are recursing */
oSettings.__fnUpdateDeep = true;
for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
{
this.fnUpdate( _fnGetCellData( oSettings, iRow, i ), iRow, i, false, false );
}
oSettings.__fnUpdateDeep = undefined;
}
else if ( oSettings.__fnUpdateDeep === undefined && mData !== null && typeof mData === 'object' )
else if ( $.isPlainObject(mData) && iColumn === undefined )
{
/* Object update - update the whole row - assume the developer gets the object right */
oSettings.aoData[iRow]._aData = $.extend( true, {}, mData );
oSettings.__fnUpdateDeep = true;
for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
{
this.fnUpdate( _fnGetCellData( oSettings, iRow, i ), iRow, i, false, false );
}
oSettings.__fnUpdateDeep = undefined;
}
else
{

View File

@ -1186,30 +1186,26 @@ this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
var iRow = (typeof mRow === 'object') ?
_fnNodeToDataIndex(oSettings, mRow) : mRow;
if ( oSettings.__fnUpdateDeep === undefined && $.isArray(mData) && typeof mData === 'object' )
if ( $.isArray(mData) && iColumn === undefined )
{
/* Array update - update the whole row */
oSettings.aoData[iRow]._aData = mData.slice();
/* Flag to the function that we are recursing */
oSettings.__fnUpdateDeep = true;
for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
{
this.fnUpdate( _fnGetCellData( oSettings, iRow, i ), iRow, i, false, false );
}
oSettings.__fnUpdateDeep = undefined;
}
else if ( oSettings.__fnUpdateDeep === undefined && mData !== null && typeof mData === 'object' )
else if ( $.isPlainObject(mData) && iColumn === undefined )
{
/* Object update - update the whole row - assume the developer gets the object right */
oSettings.aoData[iRow]._aData = $.extend( true, {}, mData );
oSettings.__fnUpdateDeep = true;
for ( i=0 ; i<oSettings.aoColumns.length ; i++ )
{
this.fnUpdate( _fnGetCellData( oSettings, iRow, i ), iRow, i, false, false );
}
oSettings.__fnUpdateDeep = undefined;
}
else
{