| 1 |
// DATA_TEMPLATE: js_data |
| 2 |
oTest.fnStart( "aoColumns.sClass" ); |
| 3 |
|
| 4 |
$(document).ready( function () { |
| 5 |
/* Check the default */ |
| 6 |
var oTable = $('#example').dataTable( { |
| 7 |
"aaData": gaaData |
| 8 |
} ); |
| 9 |
var oSettings = oTable.fnSettings(); |
| 10 |
|
| 11 |
oTest.fnTest( |
| 12 |
"By default the test class hasn't been applied to the column (sanity!)", |
| 13 |
null, |
| 14 |
function () { return $('#example tbody tr:eq(0) td:eq(2)').hasClass('unittest') == false; } |
| 15 |
); |
| 16 |
|
| 17 |
oTest.fnTest( |
| 18 |
"Add a class to a single column - first row", |
| 19 |
function () { |
| 20 |
oSession.fnRestore(); |
| 21 |
$('#example').dataTable( { |
| 22 |
"aaData": gaaData, |
| 23 |
"aoColumns": [ |
| 24 |
null, |
| 25 |
null, |
| 26 |
{ "sClass": 'unittest' }, |
| 27 |
null, |
| 28 |
null |
| 29 |
] |
| 30 |
} ); |
| 31 |
}, |
| 32 |
function () { return $('#example tbody tr:eq(1) td:eq(2)').hasClass('unittest'); } |
| 33 |
); |
| 34 |
|
| 35 |
oTest.fnTest( |
| 36 |
"Add a class to a single column - third row", |
| 37 |
null, |
| 38 |
function () { return $('#example tbody tr:eq(3) td:eq(2)').hasClass('unittest'); } |
| 39 |
); |
| 40 |
|
| 41 |
oTest.fnTest( |
| 42 |
"Add a class to a single column - last row", |
| 43 |
null, |
| 44 |
function () { return $('#example tbody tr:eq(9) td:eq(2)').hasClass('unittest'); } |
| 45 |
); |
| 46 |
|
| 47 |
oTest.fnTest( |
| 48 |
"Add a class to a single column - has not applied to other columns - 1st", |
| 49 |
null, |
| 50 |
function () { return $('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest') == false; } |
| 51 |
); |
| 52 |
|
| 53 |
oTest.fnTest( |
| 54 |
"Add a class to a single column - has not applied to other columns - 5th", |
| 55 |
null, |
| 56 |
function () { return $('#example tbody tr:eq(3) td:eq(4)').hasClass('unittest') == false; } |
| 57 |
); |
| 58 |
|
| 59 |
oTest.fnTest( |
| 60 |
"Add a class to a single column - seventh row - second page", |
| 61 |
function () { $('#example_next').click(); }, |
| 62 |
function () { return $('#example tbody tr:eq(6) td:eq(2)').hasClass('unittest'); } |
| 63 |
); |
| 64 |
|
| 65 |
oTest.fnTest( |
| 66 |
"Add a class to a single column - has not applied to header", |
| 67 |
null, |
| 68 |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } |
| 69 |
); |
| 70 |
|
| 71 |
oTest.fnTest( |
| 72 |
"Add a class to a single column - has not applied to footer", |
| 73 |
null, |
| 74 |
function () { return $('#example thead tr:eq(3) th:eq(4)').hasClass('unittest') == false; } |
| 75 |
); |
| 76 |
|
| 77 |
|
| 78 |
oTest.fnTest( |
| 79 |
"Class defined for multiple columns - first row", |
| 80 |
function () { |
| 81 |
oSession.fnRestore(); |
| 82 |
$('#example').dataTable( { |
| 83 |
"aaData": gaaData, |
| 84 |
"aoColumns": [ |
| 85 |
{ "sClass": 'unittest2' }, |
| 86 |
null, |
| 87 |
null, |
| 88 |
{ "sClass": 'unittest1' }, |
| 89 |
null |
| 90 |
] |
| 91 |
} ); |
| 92 |
}, |
| 93 |
function () { |
| 94 |
var bReturn = |
| 95 |
$('#example tbody tr:eq(3) td:eq(0)').hasClass('unittest2') && |
| 96 |
$('#example tbody tr:eq(8) td:eq(3)').hasClass('unittest1'); |
| 97 |
return bReturn; |
| 98 |
} |
| 99 |
); |
| 100 |
|
| 101 |
oTest.fnTest( |
| 102 |
"Class defined for multiple columns - has not applied to other columns - 5th 1", |
| 103 |
null, |
| 104 |
function () { return $('#example tbody tr:eq(0) td:eq(4)').hasClass('unittest1') == false; } |
| 105 |
); |
| 106 |
|
| 107 |
oTest.fnTest( |
| 108 |
"Class defined for multiple columns - has not applied to other columns - 5th 2", |
| 109 |
null, |
| 110 |
function () { return $('#example tbody tr:eq(6) td:eq(4)').hasClass('unittest2') == false; } |
| 111 |
); |
| 112 |
|
| 113 |
|
| 114 |
oTest.fnComplete(); |
| 115 |
} ); |