1 |
// DATA_TEMPLATE: empty_table |
2 |
oTest.fnStart( "fnCreatedCell tests" ); |
3 |
|
4 |
$(document).ready( function () { |
5 |
var tmp = 0; |
6 |
var complete = false; |
7 |
|
8 |
$('#example').dataTable( { |
9 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
10 |
"aoColumnDefs": [ { |
11 |
fnCreatedCell: function () { |
12 |
tmp++; |
13 |
}, |
14 |
"aTargets": ["_all"] |
15 |
} ] |
16 |
} ); |
17 |
|
18 |
oTest.fnWaitTest( |
19 |
"Cell created is called once for each cell on init", |
20 |
null, |
21 |
function () { return tmp===285; } |
22 |
); |
23 |
|
24 |
oTest.fnTest( |
25 |
"Created isn't called back on other draws", |
26 |
function () { $('#example th:eq(1)').click(); }, |
27 |
function () { return tmp===285; } |
28 |
); |
29 |
|
30 |
oTest.fnWaitTest( |
31 |
"Four arguments for the function", |
32 |
function () { |
33 |
oSession.fnRestore(); |
34 |
tmp = true; |
35 |
complete = false; |
36 |
|
37 |
$('#example').dataTable( { |
38 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
39 |
"aoColumnDefs": [ { |
40 |
fnCreatedRow: function () { |
41 |
if ( arguments.length !== 4 ) { |
42 |
tmp = false; |
43 |
} |
44 |
}, |
45 |
"aTargets": ["_all"] |
46 |
} ], |
47 |
fnInitComplete: function () { |
48 |
complete = true; |
49 |
} |
50 |
} ); |
51 |
}, |
52 |
function () { return (tmp && complete); } |
53 |
); |
54 |
|
55 |
oTest.fnWaitTest( |
56 |
"First argument is a TD element", |
57 |
function () { |
58 |
oSession.fnRestore(); |
59 |
tmp = true; |
60 |
complete = false; |
61 |
|
62 |
$('#example').dataTable( { |
63 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
64 |
"aoColumnDefs": [ { |
65 |
fnCreatedRow: function () { |
66 |
if ( arguments[0].nodeName !== "TD" ) { |
67 |
tmp = false; |
68 |
} |
69 |
}, |
70 |
"aTargets": ["_all"] |
71 |
} ], |
72 |
fnInitComplete: function () { |
73 |
complete = true; |
74 |
} |
75 |
} ); |
76 |
}, |
77 |
function () { return (tmp && complete); } |
78 |
); |
79 |
|
80 |
oTest.fnWaitTest( |
81 |
"Second argument is the HTML value", |
82 |
function () { |
83 |
oSession.fnRestore(); |
84 |
tmp = true; |
85 |
complete = false; |
86 |
|
87 |
$('#example').dataTable( { |
88 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
89 |
"aoColumnDefs": [ { |
90 |
fnCreatedRow: function () { |
91 |
if ( arguments[1] != $('td').html() ) { |
92 |
tmp = false; |
93 |
} |
94 |
}, |
95 |
"aTargets": ["_all"] |
96 |
} ], |
97 |
fnInitComplete: function () { |
98 |
complete = true; |
99 |
} |
100 |
} ); |
101 |
}, |
102 |
function () { return (tmp && complete); } |
103 |
); |
104 |
|
105 |
oTest.fnWaitTest( |
106 |
"Third argument is the data array", |
107 |
function () { |
108 |
oSession.fnRestore(); |
109 |
tmp = true; |
110 |
complete = false; |
111 |
|
112 |
$('#example').dataTable( { |
113 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
114 |
"aoColumnDefs": [ { |
115 |
fnCreatedRow: function () { |
116 |
if ( arguments[2].length !== 5 ) { |
117 |
tmp = false; |
118 |
} |
119 |
}, |
120 |
"aTargets": ["_all"] |
121 |
} ], |
122 |
fnInitComplete: function () { |
123 |
complete = true; |
124 |
} |
125 |
} ); |
126 |
}, |
127 |
function () { return (tmp && complete); } |
128 |
); |
129 |
|
130 |
oTest.fnWaitTest( |
131 |
"Fourth argument is the data source for the row", |
132 |
function () { |
133 |
oSession.fnRestore(); |
134 |
tmp = true; |
135 |
complete = false; |
136 |
|
137 |
$('#example').dataTable( { |
138 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
139 |
"aoColumnDefs": [ { |
140 |
fnCreatedRow: function () { |
141 |
if ( arguments[2] !== this.fnSettings().aoData[ arguments[2] ]._aData ) { |
142 |
tmp = false; |
143 |
} |
144 |
}, |
145 |
"aTargets": ["_all"] |
146 |
} ], |
147 |
fnInitComplete: function () { |
148 |
complete = true; |
149 |
} |
150 |
} ); |
151 |
}, |
152 |
function () { return (tmp && complete); } |
153 |
); |
154 |
|
155 |
oTest.fnWaitTest( |
156 |
"Fifth argument is the the col index", |
157 |
function () { |
158 |
oSession.fnRestore(); |
159 |
tmp = true; |
160 |
complete = false; |
161 |
|
162 |
$('#example').dataTable( { |
163 |
"sAjaxSource": "../../../examples/ajax/sources/arrays.txt", |
164 |
"aoColumnDefs": [ { |
165 |
fnCreatedRow: function () { |
166 |
if ( arguments[1] != $('td:eq('+arguments[4]+')', arguments[0].parentNode).html() ) { |
167 |
tmp = false; |
168 |
} |
169 |
}, |
170 |
"aTargets": ["_all"] |
171 |
} ], |
172 |
fnInitComplete: function () { |
173 |
complete = true; |
174 |
} |
175 |
} ); |
176 |
}, |
177 |
function () { return (tmp && complete); } |
178 |
); |
179 |
|
180 |
|
181 |
|
182 |
oTest.fnComplete(); |
183 |
} ); |