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