diff --git a/js/core/core.data.js b/js/core/core.data.js index 05721a538..18b6320fa 100644 --- a/js/core/core.data.js +++ b/js/core/core.data.js @@ -150,7 +150,11 @@ function _fnGetCellData( settings, rowIdx, colIdx, type ) else if ( typeof cellData === 'function' ) { // If the data source is a function, then we run it and use the return, // executing in the scope of the data object (for instances) - return cellData.call( rowData ); + if (col.renderReturnType === 'function') { + return cellData; + } else { + return cellData.call(rowData) + } } if ( cellData === null && type === 'display' ) { @@ -311,7 +315,13 @@ function _fnInvalidate( settings, rowIdx, src, colIdx ) cell.removeChild( cell.firstChild ); } - cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' ); + var cellData = _fnGetCellData( settings, rowIdx, col, 'display' ); + if (typeof cellData === 'string') { + cell.innerHTML = cellData; + } else if (typeof cellData === 'function') { + var targetCol = settings.aoColumns[col] + cellData(cell, targetCol.mData ? row._aData[targetCol.mData] : col.sDefaultContent, row._aData, rowIdx) + } }; // Are we reading last data from DOM or the data object? diff --git a/js/core/core.draw.js b/js/core/core.draw.js index 588d4b137..3489733a0 100644 --- a/js/core/core.draw.js +++ b/js/core/core.draw.js @@ -50,7 +50,14 @@ function _fnCreateTr ( oSettings, iRow, nTrIn, anTds ) if ( create || ((oCol.mRender || oCol.mData !== i) && (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display') )) { - nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' ); + + var cellData = _fnGetCellData( oSettings, iRow, i, 'display' ); + + if (typeof cellData === 'string') { + nTd.innerHTML = cellData; + } else if (typeof cellData === 'function') { + cellData(nTd, oCol.mData ? row._aData[oCol.mData] : oCol.sDefaultContent, row._aData, iRow) + } } /* Add user defined class */