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/objects.txt",
10 { "mData": "browser" },
11 { "mData": "platform" },
12 { "mData": "version" },
16 var oSettings = oTable.fnSettings();
19 "All columns are sortable by default",
20 function () { $('#example thead th:eq(1)').click(); },
21 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "All others"; }
25 "Can disable sorting from one column",
28 $('#example').dataTable( {
29 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
31 { "mData": "engine" },
32 { "mData": "browser", "bSortable": false },
33 { "mData": "platform" },
34 { "mData": "version" },
38 $('#example thead th:eq(1)').click();
40 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
44 "Disabled column has no sorting class",
46 function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") == false; }
50 "Other columns can still sort",
52 $('#example thead th:eq(4)').click();
53 $('#example thead th:eq(4)').click();
55 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }
59 "Disable sorting on multiple columns - no sorting classes",
62 $('#example').dataTable( {
63 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
65 { "mData": "engine" },
66 { "mData": "browser", "bSortable": false },
67 { "mData": "platform" },
68 { "mData": "version", "bSortable": false },
75 $('#example thead th:eq(1)').hasClass("sorting") ||
76 $('#example thead th:eq(3)').hasClass("sorting")
77 return bReturn == false;
82 "Sorting on disabled column 1 has no effect",
84 $('#example thead th:eq(1)').click();
86 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() != "All others"; }
90 "Sorting on disabled column 2 has no effect",
92 $('#example thead th:eq(3)').click();
94 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
98 "Second sort on disabled column 2 has no effect",
100 $('#example thead th:eq(3)').click();
102 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() != "-"; }
106 "Even with multiple disabled sorting columns other columns can still sort",
108 $('#example thead th:eq(4)').click();
109 $('#example thead th:eq(4)').click();
111 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == "X"; }