1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-30 23:52:11 +01:00

New: fnRender update - data object now also contains mDataProp along with the other information from before. There is also a second parameter passed to the function - the current value of the cell (was possible to get it from the data array, but this makes life a little easier if you want to get just that, which is the most common usage here).

This commit is contained in:
Allan Jardine 2011-12-23 18:31:25 +00:00
parent 2213cef905
commit 94542c810a
6 changed files with 44 additions and 30 deletions

View File

@ -16,8 +16,8 @@
$('#example').dataTable( {
"aoColumnDefs": [
{
"fnRender": function ( oObj ) {
return oObj.aData[0] +' '+ oObj.aData[3];
"fnRender": function ( oObj, sVal ) {
return sVal +' '+ oObj.aData[3];
},
"aTargets": [ 0 ]
},
@ -469,8 +469,8 @@
$('#example').dataTable( {
"aoColumnDefs": [
{
"fnRender": function ( oObj ) {
return oObj.aData[0] +' '+ oObj.aData[3];
"fnRender": function ( oObj, sVal ) {
return sVal +' '+ oObj.aData[3];
},
"aTargets": [ 0 ]
},

View File

@ -463,8 +463,9 @@
"iDataRow": iRow,
"iDataColumn": i,
"aData": oData._aData,
"oSettings": oSettings
} ) );
"oSettings": oSettings,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, i, 'display') ) );
}
/* See if we should auto-detect the column type */
@ -627,8 +628,9 @@
"iDataRow": iRow,
"iDataColumn": iColumn,
"aData": oData._aData,
"oSettings": oSettings
} );
"oSettings": oSettings,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, iColumn, 'display') );
nCell.innerHTML = sRendered;
if ( oCol.bUseRendered )
{
@ -1006,8 +1008,9 @@
"iDataRow": iRow,
"iDataColumn": i,
"aData": oData._aData,
"oSettings": oSettings
} );
"oSettings": oSettings,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, i, 'display') );
}
else
{
@ -5798,16 +5801,18 @@
sDisplay = mData;
_fnSetCellData( oSettings, iRow, iColumn, sDisplay );
if ( oSettings.aoColumns[iColumn].fnRender !== null )
var oCol = oSettings.aoColumns[iColumn];
if ( oCol.fnRender !== null )
{
sDisplay = oSettings.aoColumns[iColumn].fnRender( {
sDisplay = oCol.fnRender( {
"iDataRow": iRow,
"iDataColumn": iColumn,
"aData": oSettings.aoData[iRow]._aData,
"oSettings": oSettings
} );
"oSettings": oSettings,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, iColumn, 'display') );
if ( oSettings.aoColumns[iColumn].bUseRendered )
if ( oCol.bUseRendered )
{
_fnSetCellData( oSettings, iRow, iColumn, sDisplay );
}
@ -9363,6 +9368,8 @@
* @param {int} o.iDataColumn The column in question
* @param {array o.aData The data for the row in question
* @param {object} o.oSettings The settings object for this DataTables instance
* @param {object} o.mDataProp The data property used for this column
* @param {*} val The current cell value
* @returns {string} The string you which to use in the display
*
* @example
@ -9371,7 +9378,7 @@
* $('#example').dataTable( {
* "aoColumnDefs": [
* {
* "fnRender": function ( o ) {
* "fnRender": function ( o, val ) {
* return o.aData[0] +' '+ o.aData[3];
* },
* "aTargets": [ 0 ]
@ -9385,7 +9392,7 @@
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "fnRender": function ( o ) {
* { "fnRender": function ( o, val ) {
* return o.aData[0] +' '+ o.aData[3];
* } },
* null,

View File

@ -1082,16 +1082,18 @@ this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
sDisplay = mData;
_fnSetCellData( oSettings, iRow, iColumn, sDisplay );
if ( oSettings.aoColumns[iColumn].fnRender !== null )
var oCol = oSettings.aoColumns[iColumn];
if ( oCol.fnRender !== null )
{
sDisplay = oSettings.aoColumns[iColumn].fnRender( {
sDisplay = oCol.fnRender( {
"iDataRow": iRow,
"iDataColumn": iColumn,
"aData": oSettings.aoData[iRow]._aData,
"oSettings": oSettings
} );
"oSettings": oSettings,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, iColumn, 'display') );
if ( oSettings.aoColumns[iColumn].bUseRendered )
if ( oCol.bUseRendered )
{
_fnSetCellData( oSettings, iRow, iColumn, sDisplay );
}

View File

@ -38,8 +38,9 @@ function _fnAddData ( oSettings, aDataSupplied )
"iDataRow": iRow,
"iDataColumn": i,
"aData": oData._aData,
"oSettings": oSettings
} ) );
"oSettings": oSettings,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, i, 'display') ) );
}
/* See if we should auto-detect the column type */
@ -202,8 +203,9 @@ function _fnGatherData( oSettings )
"iDataRow": iRow,
"iDataColumn": iColumn,
"aData": oData._aData,
"oSettings": oSettings
} );
"oSettings": oSettings,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, iColumn, 'display') );
nCell.innerHTML = sRendered;
if ( oCol.bUseRendered )
{

View File

@ -41,8 +41,9 @@ function _fnCreateTr ( oSettings, iRow )
"iDataRow": iRow,
"iDataColumn": i,
"aData": oData._aData,
"oSettings": oSettings
} );
"oSettings": oSettings,
"mDataProp": oCol.mDataProp
}, _fnGetCellData(oSettings, iRow, i, 'display') );
}
else
{

View File

@ -249,6 +249,8 @@ DataTable.defaults.columns = {
* @param {int} o.iDataColumn The column in question
* @param {array o.aData The data for the row in question
* @param {object} o.oSettings The settings object for this DataTables instance
* @param {object} o.mDataProp The data property used for this column
* @param {*} val The current cell value
* @returns {string} The string you which to use in the display
*
* @example
@ -257,7 +259,7 @@ DataTable.defaults.columns = {
* $('#example').dataTable( {
* "aoColumnDefs": [
* {
* "fnRender": function ( o ) {
* "fnRender": function ( o, val ) {
* return o.aData[0] +' '+ o.aData[3];
* },
* "aTargets": [ 0 ]
@ -271,7 +273,7 @@ DataTable.defaults.columns = {
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumns": [
* { "fnRender": function ( o ) {
* { "fnRender": function ( o, val ) {
* return o.aData[0] +' '+ o.aData[3];
* } },
* null,