1 // DATA_TEMPLATE: empty_table
3 * NOTE: There are some differences in this zero config script for server-side
4 * processing compared to the other data sources. The main reason for this is the
5 * difference in how the server-side processing does it's filtering. Also the
6 * sorting state is always reset on each draw.
8 oTest.fnStart( "Sanity checks for DataTables with data from JS" );
11 "jQuery.dataTable function",
13 function () { return typeof jQuery().dataTable == "function"; }
17 "jQuery.dataTableSettings storage array",
19 function () { return typeof jQuery().dataTableSettings == "object"; }
23 "jQuery.dataTableExt plugin object",
25 function () { return typeof jQuery().dataTableExt == "object"; }
28 $(document).ready( function () {
29 $('#example').dataTable( {
31 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php"
36 "Length changing div exists",
38 function () { return document.getElementById('example_length') != null; }
42 "Filtering div exists",
44 function () { return document.getElementById('example_filter') != null; }
48 "Information div exists",
50 function () { return document.getElementById('example_info') != null; }
54 "Pagination div exists",
56 function () { return document.getElementById('example_paginate') != null; }
60 "Processing div is off by default",
62 function () { return document.getElementById('example_processing') == null; }
66 "10 rows shown on the first page",
68 function () { return $('#example tbody tr').length == 10; }
72 "Initial sort occured",
74 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
77 /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
79 "Sorting (first click) on second column",
80 function () { $('#example thead th:eq(1)').click(); },
81 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
85 "Sorting (second click) on second column",
86 function () { $('#example thead th:eq(1)').click(); },
87 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
91 "Sorting (third click) on second column",
92 function () { $('#example thead th:eq(1)').click(); },
93 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
97 "Sorting (first click) on numeric column",
98 function () { $('#example thead th:eq(3)').click(); },
99 function () { return $('#example tbody td:eq(3)').html() == "-"; }
103 "Sorting (second click) on numeric column",
104 function () { $('#example thead th:eq(3)').click(); },
105 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
109 "Sorting multi-column (first click)",
111 $('#example thead th:eq(0)').click();
112 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
113 function () { var b =
114 $('#example tbody td:eq(0)').html() == "Gecko" &&
115 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
119 "Sorting multi-column - sorting first column only",
121 $('#example thead th:eq(0)').click(); },
122 function () { var b =
123 $('#example tbody td:eq(0)').html() == "Gecko" &&
124 $('#example tbody td:eq(1)').html() == "Firefox 1.0"; return b; }
129 "Paging to second page",
130 function () { $('#example_next').click(); },
131 function () { return $('#example tbody td:eq(1)').html() == "Mozilla 1.1"; }
135 "Paging to first page",
136 function () { $('#example_previous').click(); },
137 function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; }
141 "Attempting to page back beyond the first page",
142 function () { $('#example_previous').click(); },
143 function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; }
146 /* Changing length */
148 "Changing table length to 25 records",
149 function () { $("select[name=example_length]").val('25').change(); },
150 function () { return $('#example tbody tr').length == 25; }
154 "Changing table length to 50 records",
155 function () { $("select[name=example_length]").val('50').change(); },
156 function () { return $('#example tbody tr').length == 50; }
160 "Changing table length to 100 records",
161 function () { $("select[name=example_length]").val('100').change(); },
162 function () { return $('#example tbody tr').length == 57; }
166 "Changing table length to 10 records",
167 function () { $("select[name=example_length]").val('10').change(); },
168 function () { return $('#example tbody tr').length == 10; }
172 * Information element
175 "Information on zero config",
177 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
181 "Information on second page",
182 function () { $('#example_next').click(); },
183 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
187 "Information on third page",
188 function () { $('#example_next').click(); },
189 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
193 "Information on last page",
195 $('#example_next').click();
196 $('#example_next').click();
197 $('#example_next').click();
199 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
203 "Information back on first page",
205 $('#example_previous').click();
206 $('#example_previous').click();
207 $('#example_previous').click();
208 $('#example_previous').click();
209 $('#example_previous').click();
211 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
215 "Information with 25 records",
216 function () { $("select[name=example_length]").val('25').change(); },
217 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; }
221 "Information with 25 records - second page",
222 function () { $('#example_next').click(); },
223 function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; }
227 "Information with 100 records - first page",
229 $('#example_previous').click();
230 $("select[name=example_length]").val('100').change();
232 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
236 "Information back to 10 records",
238 $('#example_previous').click();
239 $("select[name=example_length]").val('10').change();
241 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
245 "Information with filter 'Win'",
246 function () { $('#example_filter input').val("Win").keyup(); },
247 function () { return document.getElementById('example_info').innerHTML ==
248 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
252 "Information with filter 'Win' second page",
253 function () { $('#example_next').click(); },
254 function () { return document.getElementById('example_info').innerHTML ==
255 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
259 "Information with filter 'Win' last page",
261 $('#example_next').click();
262 $('#example_next').click();
264 function () { return document.getElementById('example_info').innerHTML ==
265 "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
269 "Information with filter 'Win' back to first page",
271 $('#example_previous').click();
272 $('#example_previous').click();
273 $('#example_previous').click();
275 function () { return document.getElementById('example_info').innerHTML ==
276 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
280 "Information with filter 'Win' second page - second time",
282 $('#example_next').click();
284 function () { return document.getElementById('example_info').innerHTML ==
285 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
289 "Information with filter increased to 'Win 98'",
290 function () { $('#example_filter input').val("Win 98").keyup(); },
291 function () { return document.getElementById('example_info').innerHTML ==
292 "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
296 "Information with filter decreased to 'Win'",
297 function () { $('#example_filter input').val("Win").keyup(); },
298 function () { return document.getElementById('example_info').innerHTML ==
299 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
303 "Information with filter 'Win' second page - third time",
305 $('#example_next').click();
307 function () { return document.getElementById('example_info').innerHTML ==
308 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
312 "Information with filter removed",
313 function () { $('#example_filter input').val("").keyup(); },
314 function () { return document.getElementById('example_info').innerHTML ==
315 "Showing 1 to 10 of 57 entries"; }
325 $('#example_filter input').val("W").keyup(); },
326 function () { return $('#example tbody tr:eq(4) td:eq(1)').html() == "Netscape 7.2"; }
332 function () { return document.getElementById('example_info').innerHTML ==
333 "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
338 function () { $('#example_filter input').val("Wi").keyup(); },
339 function () { return document.getElementById('example_info').innerHTML ==
340 "Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; }
345 function () { $('#example_filter input').val("Win").keyup(); },
346 function () { return document.getElementById('example_info').innerHTML ==
347 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
351 "Filter 'Win' - sorting column 1",
352 function () { $('#example thead th:eq(1)').click(); },
353 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; }
357 "Filter 'Win' - sorting column 1 info",
359 function () { return document.getElementById('example_info').innerHTML ==
360 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
364 "Filter 'Win' - sorting column 1 reverse",
365 function () { $('#example thead th:eq(1)').click(); },
366 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; }
370 "Filter 'Win XP' - maintaing reverse sorting col 1",
371 function () { $('#example_filter input').val("Win XP").keyup(); },
372 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; }
376 "Filter 'Win XP' - sorting col 3",
377 function () { $('#example thead th:eq(3)').click(); },
378 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "6"; }
381 /* Note the filtering is different from the DOM since the server doesn't do
382 * "smart filtering" like the client side does
385 "Filter 'Win XP' - sorting col 3 - reversed",
386 function () { $('#example thead th:eq(3)').click(); },
387 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; }
391 "Filter 'Win' - sorting col 3 - reversed info",
393 function () { return document.getElementById('example_info').innerHTML ==
394 "Showing 1 to 2 of 2 entries (filtered from 57 total entries)"; }
398 "Filter 'nothinghere'",
399 function () { $('#example_filter input').val("nothinghere").keyup(); },
400 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() ==
401 "No matching records found"; }
405 "Filter 'nothinghere' - info",
407 function () { return document.getElementById('example_info').innerHTML ==
408 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
412 "Filter back to blank and 1st column sorting",
414 $('#example_filter input').val("").keyup();
415 $('#example thead th:eq(0)').click();
417 function () { return document.getElementById('example_info').innerHTML ==
418 "Showing 1 to 10 of 57 entries"; }