2011-04-19 20:35:33 +02:00
|
|
|
// DATA_TEMPLATE: empty_table
|
|
|
|
oTest.fnStart( "aoColumns.fnRender" );
|
|
|
|
|
|
|
|
$(document).ready( function () {
|
|
|
|
/* Check the default */
|
|
|
|
var mTmp = 0;
|
|
|
|
var oTable = $('#example').dataTable( {
|
|
|
|
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
|
|
|
|
"aoColumns": [
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "engine" },
|
2011-04-19 20:35:33 +02:00
|
|
|
{
|
2012-06-29 21:10:15 +02:00
|
|
|
"mData": "browser",
|
2011-04-19 20:35:33 +02:00
|
|
|
"fnRender": function (a) {
|
|
|
|
mTmp++;
|
|
|
|
return a.aData['browser'];
|
|
|
|
}
|
|
|
|
},
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "platform" },
|
|
|
|
{ "mData": "version" },
|
|
|
|
{ "mData": "grade" }
|
2011-04-19 20:35:33 +02:00
|
|
|
]
|
|
|
|
} );
|
|
|
|
var oSettings = oTable.fnSettings();
|
|
|
|
|
|
|
|
oTest.fnWaitTest(
|
2011-04-22 20:51:06 +02:00
|
|
|
"Single column - fnRender is called twice for each row",
|
2011-04-19 20:35:33 +02:00
|
|
|
null,
|
2011-05-02 23:32:54 +02:00
|
|
|
function () { return mTmp == 57; }
|
2011-04-19 20:35:33 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
oTest.fnWaitTest(
|
2011-12-27 14:54:22 +01:00
|
|
|
"Confirm that fnRender passes two arguments with four parameters",
|
2011-04-19 20:35:33 +02:00
|
|
|
function () {
|
|
|
|
mTmp = true;
|
|
|
|
oSession.fnRestore();
|
|
|
|
oTable = $('#example').dataTable( {
|
|
|
|
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
|
|
|
|
"aoColumns": [
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "engine" },
|
2011-04-19 20:35:33 +02:00
|
|
|
{
|
|
|
|
"fnRender": function (a) {
|
2011-12-27 14:54:22 +01:00
|
|
|
if ( arguments.length != 2 || typeof a.iDataRow=='undefined' ||
|
|
|
|
typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ||
|
2012-06-29 21:10:15 +02:00
|
|
|
typeof a.mData=='undefined' )
|
2011-04-19 20:35:33 +02:00
|
|
|
{
|
|
|
|
mTmp = false;
|
|
|
|
}
|
|
|
|
return a.aData['browser'];
|
|
|
|
},
|
2012-06-29 21:10:15 +02:00
|
|
|
"mData": "browser"
|
2011-04-19 20:35:33 +02:00
|
|
|
},
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "platform" },
|
|
|
|
{ "mData": "version" },
|
|
|
|
{ "mData": "grade" }
|
2011-04-19 20:35:33 +02:00
|
|
|
]
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
function () { return mTmp; }
|
|
|
|
);
|
|
|
|
|
|
|
|
oTest.fnWaitTest(
|
|
|
|
"fnRender iDataColumn is the column",
|
|
|
|
function () {
|
|
|
|
mTmp = true;
|
|
|
|
oSession.fnRestore();
|
|
|
|
oTable = $('#example').dataTable( {
|
|
|
|
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
|
|
|
|
"aoColumns": [
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "engine" },
|
2011-04-19 20:35:33 +02:00
|
|
|
{
|
2012-06-29 21:10:15 +02:00
|
|
|
"mData": "browser",
|
2011-04-19 20:35:33 +02:00
|
|
|
"fnRender": function (a) {
|
|
|
|
if ( a.iDataColumn != 1 )
|
|
|
|
{
|
|
|
|
mTmp = false;
|
|
|
|
}
|
|
|
|
return a.aData['browser'];
|
|
|
|
}
|
|
|
|
},
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "platform" },
|
|
|
|
{ "mData": "version" },
|
|
|
|
{ "mData": "grade" }
|
2011-04-19 20:35:33 +02:00
|
|
|
]
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
function () { return mTmp; }
|
|
|
|
);
|
|
|
|
|
|
|
|
oTest.fnWaitTest(
|
|
|
|
"fnRender aData is data array of correct size",
|
|
|
|
function () {
|
|
|
|
mTmp = true;
|
|
|
|
oSession.fnRestore();
|
|
|
|
oTable = $('#example').dataTable( {
|
|
|
|
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
|
|
|
|
"aoColumns": [
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "engine" },
|
2011-04-19 20:35:33 +02:00
|
|
|
{
|
2012-06-29 21:10:15 +02:00
|
|
|
"mData": "browser",
|
2011-04-19 20:35:33 +02:00
|
|
|
"fnRender": function (a) {
|
|
|
|
if ( a.aData.length != 5 )
|
|
|
|
{
|
|
|
|
mTmp = false;
|
|
|
|
}
|
|
|
|
return a.aData['browser'];
|
|
|
|
}
|
|
|
|
},
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "platform" },
|
|
|
|
{ "mData": "version" },
|
|
|
|
{ "mData": "grade" }
|
2011-04-19 20:35:33 +02:00
|
|
|
]
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
function () { return mTmp; }
|
|
|
|
);
|
|
|
|
|
|
|
|
oTest.fnWaitTest(
|
|
|
|
"Passed back data is put into the DOM",
|
|
|
|
function () {
|
|
|
|
oSession.fnRestore();
|
|
|
|
oTable = $('#example').dataTable( {
|
|
|
|
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
|
|
|
|
"aoColumns": [
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "engine" },
|
2011-04-19 20:35:33 +02:00
|
|
|
{
|
2012-06-29 21:10:15 +02:00
|
|
|
"mData": "browser",
|
2011-04-19 20:35:33 +02:00
|
|
|
"fnRender": function (a) {
|
|
|
|
return 'unittest';
|
|
|
|
}
|
|
|
|
},
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "platform" },
|
|
|
|
{ "mData": "version" },
|
|
|
|
{ "mData": "grade" }
|
2011-04-19 20:35:33 +02:00
|
|
|
]
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; }
|
|
|
|
);
|
|
|
|
|
|
|
|
oTest.fnWaitTest(
|
|
|
|
"Passed back data is put into the DOM",
|
|
|
|
function () {
|
|
|
|
oSession.fnRestore();
|
|
|
|
oTable = $('#example').dataTable( {
|
|
|
|
"sAjaxSource": "../../../examples/ajax/sources/objects.txt",
|
|
|
|
"aoColumns": [
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "engine" },
|
|
|
|
{ "mData": "browser" },
|
2011-04-19 20:35:33 +02:00
|
|
|
{
|
2012-06-29 21:10:15 +02:00
|
|
|
"mData": "platform",
|
2011-04-19 20:35:33 +02:00
|
|
|
"fnRender": function (a) {
|
|
|
|
return 'unittest1';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2012-06-29 21:10:15 +02:00
|
|
|
"mData": "version",
|
2011-04-19 20:35:33 +02:00
|
|
|
"fnRender": function (a) {
|
|
|
|
return 'unittest2';
|
|
|
|
}
|
|
|
|
},
|
2012-06-29 21:10:15 +02:00
|
|
|
{ "mData": "grade" }
|
2011-04-19 20:35:33 +02:00
|
|
|
]
|
|
|
|
} );
|
|
|
|
},
|
|
|
|
function () {
|
|
|
|
var bReturn =
|
|
|
|
$('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' &&
|
|
|
|
$('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2';
|
|
|
|
return bReturn; }
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
oTest.fnComplete();
|
|
|
|
} );
|