1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "bSort" );
4 $(document).ready( function () {
5 /* Check the default */
6 $('#example').dataTable( {
7 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
10 { "mData": "browser" },
11 { "mData": "platform" },
12 { "mData": "version" },
18 "Sorting is on by default",
20 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
24 "Sorting Asc by default class applied",
26 function () { return $('#example thead th:eq(0)').hasClass("sorting_asc"); }
30 "Click on second column",
31 function () { $('#example thead th:eq(1)').click(); },
32 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
36 "Sorting class removed from first column",
38 function () { return $('#example thead th:eq(0)').hasClass("sorting_asc") != true; }
42 "Sorting asc class applied to second column",
44 function () { return $('#example thead th:eq(1)').hasClass("sorting_asc"); }
48 "Reverse on second column",
49 function () { $('#example thead th:eq(1)').click(); },
50 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
54 "Sorting acs class removed from second column",
56 function () { return $('#example thead th:eq(1)').hasClass("sorting_asc") != true; }
60 "Sorting desc class applied to second column",
62 function () { return $('#example thead th:eq(1)').hasClass("sorting_desc"); }
65 /* Check can disable */
67 "Pagiantion can be disabled",
70 $('#example').dataTable( {
71 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
73 { "mData": "engine", "aTargets": [0] },
74 { "mData": "browser", "aTargets": [1] },
75 { "mData": "platform", "aTargets": [2] },
76 { "mData": "version", "aTargets": [3] },
77 { "mData": "grade", "aTargets": [4] }
82 function () { return $('#example tbody td:eq(3)').html() == "4"; }
86 "Click on second column has no effect",
87 function () { $('#example thead th:eq(1)').click(); },
88 function () { return $('#example tbody td:eq(3)').html() == "4"; }
92 "Reverse on second column has no effect",
93 function () { $('#example thead th:eq(1)').click(); },
94 function () { return $('#example tbody td:eq(3)').html() == "4"; }
97 /* Enable makes no difference */
99 "Sorting enabled override",
101 oSession.fnRestore();
102 $('#example').dataTable( {
103 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
105 { "mData": "engine", "aTargets": [0] },
106 { "mData": "browser", "aTargets": [1] },
107 { "mData": "platform", "aTargets": [2] },
108 { "mData": "version", "aTargets": [3] },
109 { "mData": "grade", "aTargets": [4] }
114 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }