diff --git a/examples/basic_init/zero_config.html b/examples/basic_init/zero_config.html
index cdea3477..62fd5334 100644
--- a/examples/basic_init/zero_config.html
+++ b/examples/basic_init/zero_config.html
@@ -13,7 +13,11 @@
diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js
index 6cb2311f..fa884ba2 100644
--- a/media/js/jquery.dataTables.js
+++ b/media/js/jquery.dataTables.js
@@ -659,12 +659,22 @@
if ( oCol.fnCreatedCell )
{
oCol.fnCreatedCell.call( oSettings.oInstance,
- nCell, _fnGetCellData( oSettings, iRow, iColumn, 'display' ), oData._aData, iRow
+ nCell, _fnGetCellData( oSettings, iRow, iColumn, 'display' ), oData._aData, iRow, iColumn
);
}
}
}
}
+
+ /* Row created callbacks */
+ if ( oSettings.aoRowCreatedCallback.length !== 0 )
+ {
+ for ( i=0, iLen=oSettings.aoData.length ; iA' );
+ * }
+ * }
+ * } );
+ * } );
+ */
+ "fnCreatedRow": null,
+
+
/**
* This function is called on every 'draw' event, and allows you to
* dynamically modify any aspect you want about the created DOM.
@@ -8165,7 +8202,6 @@
* @param {int} iDisplayIndex The display index for the current table draw
* @param {int} iDisplayIndexFull The index of the data in the full list of
* rows (after filtering)
- * @returns {node} "TR" element for the current row
*
* @example
* $(document).ready(function() {
@@ -8176,7 +8212,6 @@
* {
* $('td:eq(4)', nRow).html( 'A' );
* }
- * return nRow;
* }
* } );
* } );
@@ -9337,13 +9372,14 @@
* @param {*} sData The Data for the cell
* @param {array|object} oData The data for the whole row
* @param {int} iRow The row index for the aoData data store
+ * @param {int} iCol The column index for aoColumns
*
* @example
* $(document).ready(function() {
* $('#example').dataTable( {
* "aoColumnDefs": [ {
* "aTargets": [3],
- * "fnCreatedCell": function (nTd, sData, oData, i) {
+ * "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
* if ( sData == "1.7" ) {
* $(nTd).css('color', 'blue')
* }
@@ -10145,6 +10181,13 @@
*/
"aoDrawCallback": [],
+ /**
+ * Array of callback functions for row created function
+ * @type array
+ * @default []
+ */
+ "aoRowCreatedCallback": [],
+
/**
* Callback functions for just before the table is redrawn. A return of
* false will be used to cancel the draw.
diff --git a/media/src/core/core.constructor.js b/media/src/core/core.constructor.js
index 02b174dc..0da43531 100644
--- a/media/src/core/core.constructor.js
+++ b/media/src/core/core.constructor.js
@@ -124,15 +124,16 @@ _fnMap( oSettings, oInit, "fnCookieCallback" );
_fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
/* Callback functions which are array driven */
-_fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
-_fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
-_fnCallbackReg( oSettings, 'aoStateSave', oInit.fnStateSaveCallback, 'user' );
-_fnCallbackReg( oSettings, 'aoStateLoad', oInit.fnStateLoadCallback, 'user' );
-_fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
-_fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
-_fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
-_fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
-_fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
+_fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
+_fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
+_fnCallbackReg( oSettings, 'aoStateSave', oInit.fnStateSaveCallback, 'user' );
+_fnCallbackReg( oSettings, 'aoStateLoad', oInit.fnStateLoadCallback, 'user' );
+_fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
+_fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
+_fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
+_fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
+_fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
+_fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
if ( oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort &&
oSettings.oFeatures.bSortClasses )
diff --git a/media/src/core/core.data.js b/media/src/core/core.data.js
index 8d31dc75..93bcff20 100644
--- a/media/src/core/core.data.js
+++ b/media/src/core/core.data.js
@@ -234,12 +234,22 @@ function _fnGatherData( oSettings )
if ( oCol.fnCreatedCell )
{
oCol.fnCreatedCell.call( oSettings.oInstance,
- nCell, _fnGetCellData( oSettings, iRow, iColumn, 'display' ), oData._aData, iRow
+ nCell, _fnGetCellData( oSettings, iRow, iColumn, 'display' ), oData._aData, iRow, iColumn
);
}
}
}
}
+
+ /* Row created callbacks */
+ if ( oSettings.aoRowCreatedCallback.length !== 0 )
+ {
+ for ( i=0, iLen=oSettings.aoData.length ; iA' );
+ * }
+ * }
+ * } );
+ * } );
+ */
+ "fnCreatedRow": null,
+
+
/**
* This function is called on every 'draw' event, and allows you to
* dynamically modify any aspect you want about the created DOM.
@@ -798,7 +823,6 @@ DataTable.defaults = {
* @param {int} iDisplayIndex The display index for the current table draw
* @param {int} iDisplayIndexFull The index of the data in the full list of
* rows (after filtering)
- * @returns {node} "TR" element for the current row
*
* @example
* $(document).ready(function() {
@@ -809,7 +833,6 @@ DataTable.defaults = {
* {
* $('td:eq(4)', nRow).html( 'A' );
* }
- * return nRow;
* }
* } );
* } );
diff --git a/media/src/model/model.settings.js b/media/src/model/model.settings.js
index 112a137b..6ee29494 100644
--- a/media/src/model/model.settings.js
+++ b/media/src/model/model.settings.js
@@ -389,6 +389,13 @@ DataTable.models.oSettings = {
*/
"aoDrawCallback": [],
+ /**
+ * Array of callback functions for row created function
+ * @type array
+ * @default []
+ */
+ "aoRowCreatedCallback": [],
+
/**
* Callback functions for just before the table is redrawn. A return of
* false will be used to cancel the draw.
diff --git a/media/unit_testing/tests_onhold/1_dom/fnCreatedCell.js b/media/unit_testing/tests_onhold/1_dom/fnCreatedCell.js
new file mode 100755
index 00000000..1de49671
--- /dev/null
+++ b/media/unit_testing/tests_onhold/1_dom/fnCreatedCell.js
@@ -0,0 +1,151 @@
+// DATA_TEMPLATE: dom_data
+oTest.fnStart( "fnCreatedCell tests" );
+
+$(document).ready( function () {
+ var tmp = 0;
+
+ $('#example').dataTable( {
+ "aoColumnDefs": [ {
+ fnCreatedCell: function () {
+ tmp++;
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+
+ oTest.fnTest(
+ "Cell created is called once for each cell on init",
+ null,
+ function () { return tmp===285; }
+ );
+
+ oTest.fnTest(
+ "Created isn't called back on other draws",
+ function () { $('#example th:eq(1)').click(); },
+ function () { return tmp===285; }
+ );
+
+ oTest.fnTest(
+ "Four arguments for the function",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments.length !== 4 ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "First argument is a TD element",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[0].nodeName !== "TD" ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Second argument is the HTML value",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[1] != $('td').html() ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Third argument is the data array",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[2].length !== 5 ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Fourth argument is the data source for the row",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[2] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Fifth argument is the the col index",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[1] != $('td:eq('+arguments[4]+')', arguments[0].parentNode).html() ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+
+
+ oTest.fnComplete();
+} );
\ No newline at end of file
diff --git a/media/unit_testing/tests_onhold/1_dom/fnCreatedRow.js b/media/unit_testing/tests_onhold/1_dom/fnCreatedRow.js
new file mode 100755
index 00000000..e408f709
--- /dev/null
+++ b/media/unit_testing/tests_onhold/1_dom/fnCreatedRow.js
@@ -0,0 +1,115 @@
+// DATA_TEMPLATE: dom_data
+oTest.fnStart( "fnCreatedRow tests" );
+
+$(document).ready( function () {
+ var tmp = 0;
+
+ $('#example').dataTable( {
+ fnCreatedRow: function () {
+ tmp++;
+ }
+ } );
+
+ oTest.fnTest(
+ "Row created is called once for each row on init",
+ null,
+ function () { return tmp===57; }
+ );
+
+ oTest.fnTest(
+ "Created isn't called back on other draws",
+ function () { $('#example th:eq(1)').click(); },
+ function () { return tmp===57; }
+ );
+
+ oTest.fnTest(
+ "Three arguments for the function",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ fnCreatedRow: function () {
+ if ( arguments.length !== 3 ) {
+ tmp = false;
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "First argument is a TR element",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ fnCreatedRow: function () {
+ if ( arguments[0].nodeName !== "TR" ) {
+ tmp = false;
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Second argument is an array with 5 elements",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ fnCreatedRow: function () {
+ if ( arguments[1].length !== 5 ) {
+ tmp = false;
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Third argument is the data source for the row",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ fnCreatedRow: function () {
+ if ( arguments[1] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
+ tmp = false;
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "TR element is tied to the correct data",
+ function () {
+ oSession.fnRestore();
+ tmp = false;
+
+ $('#example').dataTable( {
+ fnCreatedRow: function (tr, data, index) {
+ if ( data[1] === "Firefox 1.0" ) {
+ if ( $('td:eq(3)', tr).html() == "1.7" ) {
+ tmp = true;
+ }
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+
+
+ oTest.fnComplete();
+} );
\ No newline at end of file
diff --git a/media/unit_testing/tests_onhold/2_js/fnCreatedCell.js b/media/unit_testing/tests_onhold/2_js/fnCreatedCell.js
new file mode 100755
index 00000000..59fe717d
--- /dev/null
+++ b/media/unit_testing/tests_onhold/2_js/fnCreatedCell.js
@@ -0,0 +1,158 @@
+// DATA_TEMPLATE: js_data
+oTest.fnStart( "fnCreatedCell tests" );
+
+$(document).ready( function () {
+ var tmp = 0;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ "aoColumnDefs": [ {
+ fnCreatedCell: function () {
+ tmp++;
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+
+ oTest.fnTest(
+ "Cell created is called once for each cell on init",
+ null,
+ function () { return tmp===285; }
+ );
+
+ oTest.fnTest(
+ "Created isn't called back on other draws",
+ function () { $('#example th:eq(1)').click(); },
+ function () { return tmp===285; }
+ );
+
+ oTest.fnTest(
+ "Four arguments for the function",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments.length !== 4 ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "First argument is a TD element",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[0].nodeName !== "TD" ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Second argument is the HTML value",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[1] != $('td').html() ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Third argument is the data array",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[2].length !== 5 ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Fourth argument is the data source for the row",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[2] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Fifth argument is the the col index",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[1] != $('td:eq('+arguments[4]+')', arguments[0].parentNode).html() ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+ },
+ function () { return tmp; }
+ );
+
+
+
+ oTest.fnComplete();
+} );
\ No newline at end of file
diff --git a/media/unit_testing/tests_onhold/2_js/fnCreatedRow.js b/media/unit_testing/tests_onhold/2_js/fnCreatedRow.js
new file mode 100755
index 00000000..72b2ddde
--- /dev/null
+++ b/media/unit_testing/tests_onhold/2_js/fnCreatedRow.js
@@ -0,0 +1,121 @@
+// DATA_TEMPLATE: js_data
+oTest.fnStart( "fnCreatedRow tests" );
+
+$(document).ready( function () {
+ var tmp = 0;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ fnCreatedRow: function () {
+ tmp++;
+ }
+ } );
+
+ oTest.fnTest(
+ "Row created is called once for each row on init",
+ null,
+ function () { return tmp===57; }
+ );
+
+ oTest.fnTest(
+ "Created isn't called back on other draws",
+ function () { $('#example th:eq(1)').click(); },
+ function () { return tmp===57; }
+ );
+
+ oTest.fnTest(
+ "Three arguments for the function",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ fnCreatedRow: function () {
+ if ( arguments.length !== 3 ) {
+ tmp = false;
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "First argument is a TR element",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ fnCreatedRow: function () {
+ if ( arguments[0].nodeName !== "TR" ) {
+ tmp = false;
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Second argument is an array with 5 elements",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ fnCreatedRow: function () {
+ if ( arguments[1].length !== 5 ) {
+ tmp = false;
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "Third argument is the data source for the row",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ fnCreatedRow: function () {
+ if ( arguments[1] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
+ tmp = false;
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+ oTest.fnTest(
+ "TR element is tied to the correct data",
+ function () {
+ oSession.fnRestore();
+ tmp = false;
+
+ $('#example').dataTable( {
+ "aaData": gaaData,
+ fnCreatedRow: function (tr, data, index) {
+ if ( data[1] === "Firefox 1.0" ) {
+ if ( $('td:eq(3)', tr).html() == "1.7" ) {
+ tmp = true;
+ }
+ }
+ }
+ } );
+ },
+ function () { return tmp; }
+ );
+
+
+
+ oTest.fnComplete();
+} );
\ No newline at end of file
diff --git a/media/unit_testing/tests_onhold/3_ajax/fnCreatedCell.js b/media/unit_testing/tests_onhold/3_ajax/fnCreatedCell.js
new file mode 100755
index 00000000..e930d052
--- /dev/null
+++ b/media/unit_testing/tests_onhold/3_ajax/fnCreatedCell.js
@@ -0,0 +1,183 @@
+// DATA_TEMPLATE: empty_table
+oTest.fnStart( "fnCreatedCell tests" );
+
+$(document).ready( function () {
+ var tmp = 0;
+ var complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ "aoColumnDefs": [ {
+ fnCreatedCell: function () {
+ tmp++;
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+
+ oTest.fnWaitTest(
+ "Cell created is called once for each cell on init",
+ null,
+ function () { return tmp===285; }
+ );
+
+ oTest.fnTest(
+ "Created isn't called back on other draws",
+ function () { $('#example th:eq(1)').click(); },
+ function () { return tmp===285; }
+ );
+
+ oTest.fnWaitTest(
+ "Four arguments for the function",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments.length !== 4 ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "First argument is a TD element",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[0].nodeName !== "TD" ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Second argument is the HTML value",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[1] != $('td').html() ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Third argument is the data array",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[2].length !== 5 ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Fourth argument is the data source for the row",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[2] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Fifth argument is the the col index",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[1] != $('td:eq('+arguments[4]+')', arguments[0].parentNode).html() ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+
+
+ oTest.fnComplete();
+} );
\ No newline at end of file
diff --git a/media/unit_testing/tests_onhold/3_ajax/fnCreatedRow.js b/media/unit_testing/tests_onhold/3_ajax/fnCreatedRow.js
new file mode 100755
index 00000000..66fc3287
--- /dev/null
+++ b/media/unit_testing/tests_onhold/3_ajax/fnCreatedRow.js
@@ -0,0 +1,142 @@
+// DATA_TEMPLATE: empty_table
+oTest.fnStart( "fnCreatedRow tests" );
+
+$(document).ready( function () {
+ var tmp = 0;
+ var complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ fnCreatedRow: function () {
+ tmp++;
+ }
+ } );
+
+ oTest.fnWaitTest(
+ "Row created is called once for each row on init",
+ null,
+ function () { return tmp===57; }
+ );
+
+ oTest.fnTest(
+ "Created isn't called back on other draws",
+ function () { $('#example th:eq(1)').click(); },
+ function () { return tmp===57; }
+ );
+
+ oTest.fnWaitTest(
+ "Three arguments for the function",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ fnCreatedRow: function () {
+ if ( arguments.length !== 3 ) {
+ tmp = false;
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "First argument is a TR element",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ fnCreatedRow: function () {
+ if ( arguments[0].nodeName !== "TR" ) {
+ tmp = false;
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Second argument is an array with 5 elements",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ fnCreatedRow: function () {
+ if ( arguments[1].length !== 5 ) {
+ tmp = false;
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Third argument is the data source for the row",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ fnCreatedRow: function () {
+ if ( arguments[1] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
+ tmp = false;
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "TR element is tied to the correct data",
+ function () {
+ oSession.fnRestore();
+ tmp = false;
+ complete = false;
+
+ $('#example').dataTable( {
+ "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
+ fnCreatedRow: function (tr, data, index) {
+ if ( data[1] === "Firefox 1.0" ) {
+ if ( $('td:eq(3)', tr).html() == "1.7" ) {
+ tmp = true;
+ }
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+
+
+ oTest.fnComplete();
+} );
\ No newline at end of file
diff --git a/media/unit_testing/tests_onhold/4_server-side/fnCreatedCell.js b/media/unit_testing/tests_onhold/4_server-side/fnCreatedCell.js
new file mode 100755
index 00000000..de76ace5
--- /dev/null
+++ b/media/unit_testing/tests_onhold/4_server-side/fnCreatedCell.js
@@ -0,0 +1,190 @@
+// DATA_TEMPLATE: empty_table
+oTest.fnStart( "fnCreatedCell tests" );
+
+$(document).ready( function () {
+ var tmp = 0;
+ var complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ "aoColumnDefs": [ {
+ fnCreatedCell: function () {
+ tmp++;
+ },
+ "aTargets": ["_all"]
+ } ]
+ } );
+
+ oTest.fnWaitTest(
+ "Cell created is called once for each cell on init",
+ null,
+ function () { return tmp===50; }
+ );
+
+ oTest.fnWaitTest(
+ "Created is called back on other draws",
+ function () { $('#example th:eq(1)').click(); },
+ function () { return tmp===100; }
+ );
+
+ oTest.fnWaitTest(
+ "Four arguments for the function",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments.length !== 4 ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "First argument is a TD element",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[0].nodeName !== "TD" ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Second argument is the HTML value",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[1] != $('td').html() ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Third argument is the data array",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[2].length !== 5 ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Fourth argument is the data source for the row",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[2] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Fifth argument is the the col index",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ "aoColumnDefs": [ {
+ fnCreatedRow: function () {
+ if ( arguments[1] != $('td:eq('+arguments[4]+')', arguments[0].parentNode).html() ) {
+ tmp = false;
+ }
+ },
+ "aTargets": ["_all"]
+ } ],
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+
+
+ oTest.fnComplete();
+} );
\ No newline at end of file
diff --git a/media/unit_testing/tests_onhold/4_server-side/fnCreatedRow.js b/media/unit_testing/tests_onhold/4_server-side/fnCreatedRow.js
new file mode 100755
index 00000000..b81eba38
--- /dev/null
+++ b/media/unit_testing/tests_onhold/4_server-side/fnCreatedRow.js
@@ -0,0 +1,148 @@
+// DATA_TEMPLATE: empty_table
+oTest.fnStart( "fnCreatedRow tests" );
+
+$(document).ready( function () {
+ var tmp = 0;
+ var complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ fnCreatedRow: function () {
+ tmp++;
+ }
+ } );
+
+ oTest.fnWaitTest(
+ "Row created is called once for each row on init",
+ null,
+ function () { return tmp===10; }
+ );
+
+ oTest.fnWaitTest(
+ "Created is called back on other draws",
+ function () { $('#example th:eq(1)').click(); },
+ function () { return tmp===20; }
+ );
+
+ oTest.fnWaitTest(
+ "Three arguments for the function",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ fnCreatedRow: function () {
+ if ( arguments.length !== 3 ) {
+ tmp = false;
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "First argument is a TR element",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ fnCreatedRow: function () {
+ if ( arguments[0].nodeName !== "TR" ) {
+ tmp = false;
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Second argument is an array with 5 elements",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ fnCreatedRow: function () {
+ if ( arguments[1].length !== 5 ) {
+ tmp = false;
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "Third argument is the data source for the row",
+ function () {
+ oSession.fnRestore();
+ tmp = true;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ fnCreatedRow: function () {
+ if ( arguments[1] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
+ tmp = false;
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+ oTest.fnWaitTest(
+ "TR element is tied to the correct data",
+ function () {
+ oSession.fnRestore();
+ tmp = false;
+ complete = false;
+
+ $('#example').dataTable( {
+ "bServerSide": true,
+ "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
+ fnCreatedRow: function (tr, data, index) {
+ if ( data[1] === "Firefox 1.0" ) {
+ if ( $('td:eq(3)', tr).html() == "1.7" ) {
+ tmp = true;
+ }
+ }
+ },
+ fnInitComplete: function () {
+ complete = true;
+ }
+ } );
+ },
+ function () { return (tmp && complete); }
+ );
+
+
+
+ oTest.fnComplete();
+} );
\ No newline at end of file