mirror of
https://github.com/DataTables/DataTables.git
synced 2025-03-15 16:29:16 +01:00
New: Add unit tests for fnCreatedCell and fnCreatedRow
New: New init option fnCreatedRow - very similar to fnCreatedCell but in this case used for TR elements Updated: fnCreatedCell now also gets the column index passed in
This commit is contained in:
parent
4808f0edd7
commit
cb014e81d7
@ -13,7 +13,11 @@
|
|||||||
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
|
<script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
|
||||||
<script type="text/javascript" charset="utf-8">
|
<script type="text/javascript" charset="utf-8">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#example').dataTable();
|
$('#example').dataTable({
|
||||||
|
fnCreatedRow: function () {
|
||||||
|
console.log( arguments );
|
||||||
|
}
|
||||||
|
});
|
||||||
} );
|
} );
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
73
media/js/jquery.dataTables.js
vendored
73
media/js/jquery.dataTables.js
vendored
@ -659,12 +659,22 @@
|
|||||||
if ( oCol.fnCreatedCell )
|
if ( oCol.fnCreatedCell )
|
||||||
{
|
{
|
||||||
oCol.fnCreatedCell.call( oSettings.oInstance,
|
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 ; i<iLen ; i++ )
|
||||||
|
{
|
||||||
|
oData = oSettings.aoData[i];
|
||||||
|
_fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [oData.nTr, oData._aData, i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1036,12 +1046,13 @@
|
|||||||
if ( oCol.fnCreatedCell )
|
if ( oCol.fnCreatedCell )
|
||||||
{
|
{
|
||||||
oCol.fnCreatedCell.call( oSettings.oInstance,
|
oCol.fnCreatedCell.call( oSettings.oInstance,
|
||||||
nTd, _fnGetCellData( oSettings, iRow, i, 'display' ), oData._aData, iRow
|
nTd, _fnGetCellData( oSettings, iRow, i, 'display' ), oData._aData, iRow, i
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
_fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [oData.nTr, oData._aData, iRow] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6148,15 +6159,16 @@
|
|||||||
_fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
|
_fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
|
||||||
|
|
||||||
/* Callback functions which are array driven */
|
/* Callback functions which are array driven */
|
||||||
_fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
|
_fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoStateSave', oInit.fnStateSaveCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoStateSave', oInit.fnStateSaveCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoStateLoad', oInit.fnStateLoadCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoStateLoad', oInit.fnStateLoadCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
|
_fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
|
||||||
|
_fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
|
||||||
|
|
||||||
if ( oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort &&
|
if ( oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort &&
|
||||||
oSettings.oFeatures.bSortClasses )
|
oSettings.oFeatures.bSortClasses )
|
||||||
@ -7959,6 +7971,31 @@
|
|||||||
"fnCookieCallback": null,
|
"fnCookieCallback": null,
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called when a TR element is created (and all TD child
|
||||||
|
* elements have been inserted), or registered if using a DOM source, allowing
|
||||||
|
* manipulation of the TR element (adding classes etc).
|
||||||
|
* @type function
|
||||||
|
* @param {node} nRow "TR" element for the current row
|
||||||
|
* @param {array} aData Raw data array for this row
|
||||||
|
* @param {int} iDataIndex The index of this row in aoData
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* $(document).ready(function() {
|
||||||
|
* $('#example').dataTable( {
|
||||||
|
* "fnCreatedRow": function( nRow, aData, iDataIndex ) {
|
||||||
|
* // Bold the grade for all 'A' grade browsers
|
||||||
|
* if ( aData[4] == "A" )
|
||||||
|
* {
|
||||||
|
* $('td:eq(4)', nRow).html( '<b>A</b>' );
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* } );
|
||||||
|
* } );
|
||||||
|
*/
|
||||||
|
"fnCreatedRow": null,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is called on every 'draw' event, and allows you to
|
* This function is called on every 'draw' event, and allows you to
|
||||||
* dynamically modify any aspect you want about the created DOM.
|
* 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} iDisplayIndex The display index for the current table draw
|
||||||
* @param {int} iDisplayIndexFull The index of the data in the full list of
|
* @param {int} iDisplayIndexFull The index of the data in the full list of
|
||||||
* rows (after filtering)
|
* rows (after filtering)
|
||||||
* @returns {node} "TR" element for the current row
|
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* $(document).ready(function() {
|
* $(document).ready(function() {
|
||||||
@ -8176,7 +8212,6 @@
|
|||||||
* {
|
* {
|
||||||
* $('td:eq(4)', nRow).html( '<b>A</b>' );
|
* $('td:eq(4)', nRow).html( '<b>A</b>' );
|
||||||
* }
|
* }
|
||||||
* return nRow;
|
|
||||||
* }
|
* }
|
||||||
* } );
|
* } );
|
||||||
* } );
|
* } );
|
||||||
@ -9337,13 +9372,14 @@
|
|||||||
* @param {*} sData The Data for the cell
|
* @param {*} sData The Data for the cell
|
||||||
* @param {array|object} oData The data for the whole row
|
* @param {array|object} oData The data for the whole row
|
||||||
* @param {int} iRow The row index for the aoData data store
|
* @param {int} iRow The row index for the aoData data store
|
||||||
|
* @param {int} iCol The column index for aoColumns
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* $(document).ready(function() {
|
* $(document).ready(function() {
|
||||||
* $('#example').dataTable( {
|
* $('#example').dataTable( {
|
||||||
* "aoColumnDefs": [ {
|
* "aoColumnDefs": [ {
|
||||||
* "aTargets": [3],
|
* "aTargets": [3],
|
||||||
* "fnCreatedCell": function (nTd, sData, oData, i) {
|
* "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
|
||||||
* if ( sData == "1.7" ) {
|
* if ( sData == "1.7" ) {
|
||||||
* $(nTd).css('color', 'blue')
|
* $(nTd).css('color', 'blue')
|
||||||
* }
|
* }
|
||||||
@ -10145,6 +10181,13 @@
|
|||||||
*/
|
*/
|
||||||
"aoDrawCallback": [],
|
"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
|
* Callback functions for just before the table is redrawn. A return of
|
||||||
* false will be used to cancel the draw.
|
* false will be used to cancel the draw.
|
||||||
|
@ -124,15 +124,16 @@ _fnMap( oSettings, oInit, "fnCookieCallback" );
|
|||||||
_fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
|
_fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
|
||||||
|
|
||||||
/* Callback functions which are array driven */
|
/* Callback functions which are array driven */
|
||||||
_fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
|
_fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoStateSave', oInit.fnStateSaveCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoStateSave', oInit.fnStateSaveCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoStateLoad', oInit.fnStateLoadCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoStateLoad', oInit.fnStateLoadCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
|
_fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
|
||||||
_fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
|
_fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
|
||||||
|
_fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
|
||||||
|
|
||||||
if ( oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort &&
|
if ( oSettings.oFeatures.bServerSide && oSettings.oFeatures.bSort &&
|
||||||
oSettings.oFeatures.bSortClasses )
|
oSettings.oFeatures.bSortClasses )
|
||||||
|
@ -234,12 +234,22 @@ function _fnGatherData( oSettings )
|
|||||||
if ( oCol.fnCreatedCell )
|
if ( oCol.fnCreatedCell )
|
||||||
{
|
{
|
||||||
oCol.fnCreatedCell.call( oSettings.oInstance,
|
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 ; i<iLen ; i++ )
|
||||||
|
{
|
||||||
|
oData = oSettings.aoData[i];
|
||||||
|
_fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [oData.nTr, oData._aData, i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,12 +69,13 @@ function _fnCreateTr ( oSettings, iRow )
|
|||||||
if ( oCol.fnCreatedCell )
|
if ( oCol.fnCreatedCell )
|
||||||
{
|
{
|
||||||
oCol.fnCreatedCell.call( oSettings.oInstance,
|
oCol.fnCreatedCell.call( oSettings.oInstance,
|
||||||
nTd, _fnGetCellData( oSettings, iRow, i, 'display' ), oData._aData, iRow
|
nTd, _fnGetCellData( oSettings, iRow, i, 'display' ), oData._aData, iRow, i
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
_fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [oData.nTr, oData._aData, iRow] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -222,13 +222,14 @@ DataTable.defaults.columns = {
|
|||||||
* @param {*} sData The Data for the cell
|
* @param {*} sData The Data for the cell
|
||||||
* @param {array|object} oData The data for the whole row
|
* @param {array|object} oData The data for the whole row
|
||||||
* @param {int} iRow The row index for the aoData data store
|
* @param {int} iRow The row index for the aoData data store
|
||||||
|
* @param {int} iCol The column index for aoColumns
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* $(document).ready(function() {
|
* $(document).ready(function() {
|
||||||
* $('#example').dataTable( {
|
* $('#example').dataTable( {
|
||||||
* "aoColumnDefs": [ {
|
* "aoColumnDefs": [ {
|
||||||
* "aTargets": [3],
|
* "aTargets": [3],
|
||||||
* "fnCreatedCell": function (nTd, sData, oData, i) {
|
* "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
|
||||||
* if ( sData == "1.7" ) {
|
* if ( sData == "1.7" ) {
|
||||||
* $(nTd).css('color', 'blue')
|
* $(nTd).css('color', 'blue')
|
||||||
* }
|
* }
|
||||||
|
@ -592,6 +592,31 @@ DataTable.defaults = {
|
|||||||
"fnCookieCallback": null,
|
"fnCookieCallback": null,
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is called when a TR element is created (and all TD child
|
||||||
|
* elements have been inserted), or registered if using a DOM source, allowing
|
||||||
|
* manipulation of the TR element (adding classes etc).
|
||||||
|
* @type function
|
||||||
|
* @param {node} nRow "TR" element for the current row
|
||||||
|
* @param {array} aData Raw data array for this row
|
||||||
|
* @param {int} iDataIndex The index of this row in aoData
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* $(document).ready(function() {
|
||||||
|
* $('#example').dataTable( {
|
||||||
|
* "fnCreatedRow": function( nRow, aData, iDataIndex ) {
|
||||||
|
* // Bold the grade for all 'A' grade browsers
|
||||||
|
* if ( aData[4] == "A" )
|
||||||
|
* {
|
||||||
|
* $('td:eq(4)', nRow).html( '<b>A</b>' );
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* } );
|
||||||
|
* } );
|
||||||
|
*/
|
||||||
|
"fnCreatedRow": null,
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is called on every 'draw' event, and allows you to
|
* This function is called on every 'draw' event, and allows you to
|
||||||
* dynamically modify any aspect you want about the created DOM.
|
* 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} iDisplayIndex The display index for the current table draw
|
||||||
* @param {int} iDisplayIndexFull The index of the data in the full list of
|
* @param {int} iDisplayIndexFull The index of the data in the full list of
|
||||||
* rows (after filtering)
|
* rows (after filtering)
|
||||||
* @returns {node} "TR" element for the current row
|
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* $(document).ready(function() {
|
* $(document).ready(function() {
|
||||||
@ -809,7 +833,6 @@ DataTable.defaults = {
|
|||||||
* {
|
* {
|
||||||
* $('td:eq(4)', nRow).html( '<b>A</b>' );
|
* $('td:eq(4)', nRow).html( '<b>A</b>' );
|
||||||
* }
|
* }
|
||||||
* return nRow;
|
|
||||||
* }
|
* }
|
||||||
* } );
|
* } );
|
||||||
* } );
|
* } );
|
||||||
|
@ -389,6 +389,13 @@ DataTable.models.oSettings = {
|
|||||||
*/
|
*/
|
||||||
"aoDrawCallback": [],
|
"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
|
* Callback functions for just before the table is redrawn. A return of
|
||||||
* false will be used to cancel the draw.
|
* false will be used to cancel the draw.
|
||||||
|
151
media/unit_testing/tests_onhold/1_dom/fnCreatedCell.js
Executable file
151
media/unit_testing/tests_onhold/1_dom/fnCreatedCell.js
Executable file
@ -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();
|
||||||
|
} );
|
115
media/unit_testing/tests_onhold/1_dom/fnCreatedRow.js
Executable file
115
media/unit_testing/tests_onhold/1_dom/fnCreatedRow.js
Executable file
@ -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();
|
||||||
|
} );
|
158
media/unit_testing/tests_onhold/2_js/fnCreatedCell.js
Executable file
158
media/unit_testing/tests_onhold/2_js/fnCreatedCell.js
Executable file
@ -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();
|
||||||
|
} );
|
121
media/unit_testing/tests_onhold/2_js/fnCreatedRow.js
Executable file
121
media/unit_testing/tests_onhold/2_js/fnCreatedRow.js
Executable file
@ -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();
|
||||||
|
} );
|
183
media/unit_testing/tests_onhold/3_ajax/fnCreatedCell.js
Executable file
183
media/unit_testing/tests_onhold/3_ajax/fnCreatedCell.js
Executable file
@ -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();
|
||||||
|
} );
|
142
media/unit_testing/tests_onhold/3_ajax/fnCreatedRow.js
Executable file
142
media/unit_testing/tests_onhold/3_ajax/fnCreatedRow.js
Executable file
@ -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();
|
||||||
|
} );
|
190
media/unit_testing/tests_onhold/4_server-side/fnCreatedCell.js
Executable file
190
media/unit_testing/tests_onhold/4_server-side/fnCreatedCell.js
Executable file
@ -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();
|
||||||
|
} );
|
148
media/unit_testing/tests_onhold/4_server-side/fnCreatedRow.js
Executable file
148
media/unit_testing/tests_onhold/4_server-side/fnCreatedRow.js
Executable file
@ -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();
|
||||||
|
} );
|
Loading…
x
Reference in New Issue
Block a user