1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "Sanity checks for DataTables with delayed DOM creation" );
4 $(document).ready( function () {
6 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
9 $('#example').dataTable( oInit );
12 "10 rows shown on the first page",
14 function () { return $('#example tbody tr').length == 10; }
18 "10 TR elements available from fnGetNodes",
20 function () { return $('#example').dataTable().fnGetNodes().length == 10; }
24 "Initial sort occured",
26 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
30 "Sorting (first click) on second column",
31 function () { $('#example thead th:eq(1)').click(); },
32 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
36 "14 TR elements available from fnGetNodes after sort",
38 function () { return $('#example').dataTable().fnGetNodes().length == 14; }
42 "Sorting (second click) on second column",
43 function () { $('#example thead th:eq(1)').click(); },
44 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
48 "Sorting (third click) on second column",
49 function () { $('#example thead th:eq(1)').click(); },
50 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
54 "Sorting (first click) on numeric column",
55 function () { $('#example thead th:eq(3)').click(); },
56 function () { return $('#example tbody td:eq(3)').html() == "-"; }
60 "Sorting (second click) on numeric column",
61 function () { $('#example thead th:eq(3)').click(); },
62 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
66 "Sorting multi-column (first click)",
68 $('#example thead th:eq(0)').click();
69 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
71 $('#example tbody td:eq(0)').html() == "Gecko" &&
72 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
76 "Sorting multi-column - sorting second column only",
78 $('#example thead th:eq(1)').click(); },
79 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
84 "Paging to second page",
85 function () { $('#example_next').click(); },
86 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
90 "Paging to first page",
91 function () { $('#example_previous').click(); },
92 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
96 "Attempting to page back beyond the first page",
97 function () { $('#example_previous').click(); },
98 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
101 /* Changing length */
103 "Changing table length to 25 records",
104 function () { $("select[name=example_length]").val('25').change(); },
105 function () { return $('#example tbody tr').length == 25; }
109 "Changing table length to 50 records",
110 function () { $("select[name=example_length]").val('50').change(); },
111 function () { return $('#example tbody tr').length == 50; }
115 "Changing table length to 100 records",
116 function () { $("select[name=example_length]").val('100').change(); },
117 function () { return $('#example tbody tr').length == 57; }
121 "Changing table length to 10 records",
122 function () { $("select[name=example_length]").val('10').change(); },
123 function () { return $('#example tbody tr').length == 10; }
127 * Information element
130 "Information on zero config",
132 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
136 "Information on second page",
137 function () { $('#example_next').click(); },
138 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
142 "Information on third page",
143 function () { $('#example_next').click(); },
144 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
148 "Information on last page",
150 $('#example_next').click();
151 $('#example_next').click();
152 $('#example_next').click();
154 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
158 "Information back on first page",
160 $('#example_previous').click();
161 $('#example_previous').click();
162 $('#example_previous').click();
163 $('#example_previous').click();
164 $('#example_previous').click();
166 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
170 "Information with 25 records",
171 function () { $("select[name=example_length]").val('25').change(); },
172 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; }
176 "Information with 25 records - second page",
177 function () { $('#example_next').click(); },
178 function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; }
182 "Information with 100 records - first page",
184 $('#example_previous').click();
185 $("select[name=example_length]").val('100').change();
187 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
191 "Information back to 10 records",
193 $('#example_previous').click();
194 $("select[name=example_length]").val('10').change();
196 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
200 "Information with filter 'Win'",
201 function () { $('#example_filter input').val("Win").keyup(); },
202 function () { return document.getElementById('example_info').innerHTML ==
203 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
207 "Information with filter 'Win' second page",
208 function () { $('#example_next').click(); },
209 function () { return document.getElementById('example_info').innerHTML ==
210 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
214 "Information with filter 'Win' last page",
216 $('#example_next').click();
217 $('#example_next').click();
219 function () { return document.getElementById('example_info').innerHTML ==
220 "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
224 "Information with filter 'Win' back to first page",
226 $('#example_previous').click();
227 $('#example_previous').click();
228 $('#example_previous').click();
230 function () { return document.getElementById('example_info').innerHTML ==
231 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
235 "Information with filter 'Win' second page - second time",
237 $('#example_next').click();
239 function () { return document.getElementById('example_info').innerHTML ==
240 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
244 "Information with filter increased to 'Win 98'",
245 function () { $('#example_filter input').val("Win 98").keyup(); },
246 function () { return document.getElementById('example_info').innerHTML ==
247 "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
251 "Information with filter decreased to 'Win'",
252 function () { $('#example_filter input').val("Win").keyup(); },
253 function () { return document.getElementById('example_info').innerHTML ==
254 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
258 "Information with filter 'Win' second page - third time",
260 $('#example_next').click();
262 function () { return document.getElementById('example_info').innerHTML ==
263 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
267 "Information with filter removed",
268 function () { $('#example_filter input').val("").keyup(); },
269 function () { return document.getElementById('example_info').innerHTML ==
270 "Showing 1 to 10 of 57 entries"; }
280 /* Reset the table such that the old sorting doesn't mess things up */
281 oSession.fnRestore();
282 $('#example').dataTable( oInit );
283 $('#example_filter input').val("W").keyup(); },
284 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
290 function () { return document.getElementById('example_info').innerHTML ==
291 "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
296 function () { $('#example_filter input').val("Wi").keyup(); },
297 function () { return document.getElementById('example_info').innerHTML ==
298 "Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; }
303 function () { $('#example_filter input').val("Win").keyup(); },
304 function () { return document.getElementById('example_info').innerHTML ==
305 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
309 "Filter 'Win' - sorting column 1",
310 function () { $('#example thead th:eq(1)').click(); },
311 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; }
315 "Filter 'Win' - sorting column 1 info",
317 function () { return document.getElementById('example_info').innerHTML ==
318 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
322 "Filter 'Win' - sorting column 1 reverse",
323 function () { $('#example thead th:eq(1)').click(); },
324 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; }
328 "Filter 'Win XP' - maintaing reverse sorting col 1",
329 function () { $('#example_filter input').val("Win XP").keyup(); },
330 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; }
334 "Filter 'Win XP' - sorting col 3",
335 function () { $('#example thead th:eq(3)').click(); },
336 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; }
340 "Filter 'Win XP' - sorting col 3 - reversed",
341 function () { $('#example thead th:eq(3)').click(); },
342 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; }
346 "Filter 'Win' - sorting col 3 - reversed info",
348 function () { return document.getElementById('example_info').innerHTML ==
349 "Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; }
353 "Filter 'nothinghere'",
354 function () { $('#example_filter input').val("nothinghere").keyup(); },
355 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() ==
356 "No matching records found"; }
360 "Filter 'nothinghere' - info",
362 function () { return document.getElementById('example_info').innerHTML ==
363 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
367 "Filter back to blank and 1st column sorting",
369 $('#example_filter input').val("").keyup();
370 $('#example thead th:eq(0)').click();
372 function () { return document.getElementById('example_info').innerHTML ==
373 "Showing 1 to 10 of 57 entries"; }
377 "Prefixing a filter entry",
379 $('#example_filter input').val("Win").keyup();
380 $('#example_filter input').val("GeckoWin").keyup();
382 function () { return document.getElementById('example_info').innerHTML ==
383 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
387 "Prefixing a filter entry with space",
389 $('#example_filter input').val("Gecko Win").keyup();
391 function () { return document.getElementById('example_info').innerHTML ==
392 "Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; }