annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.bSortable.js @ 0:ac5f9272033b draft

first upload
author saskia-hiltemann
date Tue, 01 Jul 2014 11:42:23 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1 // DATA_TEMPLATE: empty_table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 oTest.fnStart( "aoColumns.bSortable" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 /* Check the default */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 var oTable = $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 "bDeferRender": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 var oSettings = oTable.fnSettings();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 "All columns are sortable by default",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 function () { $('#example thead th:eq(1)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 "Can disable sorting from one column",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 { "bSortable": false },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 $('#example thead th:eq(1)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 "Disabled column has no sorting class",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 "Other columns can still sort",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 $('#example thead th:eq(4)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 $('#example thead th:eq(4)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 "Disable sorting on multiple columns - no sorting classes",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 oSession.fnRestore();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 $('#example').dataTable( {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 "aoColumns": [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 { "bSortable": false },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 { "bSortable": false },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65 null
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 var bReturn =
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 $('#example thead th:eq(1)').hasClass("sorting") ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 $('#example thead th:eq(3)').hasClass("sorting")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 return bReturn == false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 "Sorting on disabled column 1 has no effect",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 $('#example thead th:eq(1)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 "Sorting on disabled column 2 has no effect",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 $('#example thead th:eq(3)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 "Second sort on disabled column 2 has no effect",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96 $('#example thead th:eq(3)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102 "Even with multiple disabled sorting columns other columns can still sort",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
103 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104 $('#example thead th:eq(4)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 $('#example thead th:eq(4)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
106 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
107 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
108 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
109
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
110
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
111 oTest.fnComplete();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
112 } );