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