1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "aoColumns.bSortable" );
4 $(document).ready( function () {
5 /* Check the default */
6 var oTable = $('#example').dataTable( {
7 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt"
9 var oSettings = oTable.fnSettings();
12 "All columns are sortable by default",
13 function () { $('#example thead th:eq(1)').click(); },
14 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; }
18 "Can disable sorting from one column",
21 $('#example').dataTable( {
22 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
25 { "bSortable": false },
31 $('#example thead th:eq(1)').click();
33 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
37 "Disabled column has no sorting class",
39 function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; }
43 "Other columns can still sort",
45 $('#example thead th:eq(4)').click();
46 $('#example thead th:eq(4)').click();
48 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }
52 "Disable sorting on multiple columns - no sorting classes",
55 $('#example').dataTable( {
56 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
59 { "bSortable": false },
61 { "bSortable": false },
68 $('#example thead th:eq(1)').hasClass("sorting") ||
69 $('#example thead th:eq(3)').hasClass("sorting")
70 return bReturn == false;
75 "Sorting on disabled column 1 has no effect",
77 $('#example thead th:eq(1)').click();
79 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
83 "Sorting on disabled column 2 has no effect",
85 $('#example thead th:eq(3)').click();
87 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
91 "Second sort on disabled column 2 has no effect",
93 $('#example thead th:eq(3)').click();
95 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
99 "Even with multiple disabled sorting columns other columns can still sort",
101 $('#example thead th:eq(4)').click();
102 $('#example thead th:eq(4)').click();
104 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }