Add datatables-1.9.4 and jquery-1.10.2 libraries
[proteocache.git] / webapp / resources / datatables-1.9.4 / media / unit_testing / tests_onhold / 5_ajax_objects / aoColumns.bUseRendered.js
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "aoColumns.bUseRendered" );
3
4 /* bUseRendered is used to alter sorting data, if false then the original data is used for
5  * sorting rather than the rendered data
6  */
7
8 $(document).ready( function () {
9         /* Check the default */
10         var mTmp = 0;
11         
12         var oTable = $('#example').dataTable( {
13                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
14                 "aoColumns": [
15                         { "mData": "engine" },
16                         {
17                                 "mData": "browser",
18                                 "fnRender": function (a) {
19                                         if ( mTmp == 0 ) {
20                                                 mTmp++;
21                                                 return "aaa";
22                                         } else
23                                                 return a.aData['browser'];
24                                 }
25                         },
26                         { "mData": "platform" },
27                         { "mData": "version" },
28                         { "mData": "grade" }
29                 ]
30         } );
31         var oSettings = oTable.fnSettings();
32         
33         oTest.fnWaitTest( 
34                 "Default for bUseRendered is true - rendered data is used for sorting",
35                 function () { $('#example thead th:eq(1)').click(); },
36                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'aaa'; }
37         );
38         
39         oTest.fnWaitTest( 
40                 "When bUseRendered is false, original data is used for sorting",
41                 function () {
42                         mTmp = 0;
43                         oSession.fnRestore();
44                         oTable = $('#example').dataTable( {
45                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
46                                 "aoColumns": [
47                                         { "mData": "engine" },
48                                         { 
49                                                 "mData": "browser",
50                                                 "bUseRendered": false,
51                                                 "fnRender": function (a) {
52                                                         if ( mTmp == 0 ) {
53                                                                 mTmp++;
54                                                                 return "aaa";
55                                                         } else {
56                                                                 return a.aData['browser'];
57                                                         }
58                                                 }
59                                         },
60                                         { "mData": "platform" },
61                                         { "mData": "version" },
62                                         { "mData": "grade" }
63                                 ]
64                         } );
65                         $('#example thead th:eq(1)').click();
66                 },
67                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
68         );
69         
70         
71         oTest.fnWaitTest( 
72                 "bUseRendered set to false on one columns and true (default) on two others",
73                 function () {
74                         mTmp = 0;
75                         var mTmp2 = 0;
76                         var mTmp3 = 0;
77                         
78                         oSession.fnRestore();
79                         oTable = $('#example').dataTable( {
80                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
81                                 "aoColumns": [
82                                         {
83                                                 "mData": "engine",
84                                                 "fnRender": function (a) {
85                                                         if ( mTmp == 0 ) {
86                                                                 mTmp++;
87                                                                 return "aaa1";
88                                                         } else {
89                                                                 return a.aData['engine'];
90                                                         }
91                                                 }
92                                         },
93                                         { 
94                                                 "mData": "browser",
95                                                 "bUseRendered": false,
96                                                 "fnRender": function (a) {
97                                                         if ( mTmp2 == 0 ) {
98                                                                 mTmp2++;
99                                                                 return "aaa2";
100                                                         } else {
101                                                                 return a.aData['browser'];
102                                                         }
103                                                 }
104                                         },
105                                         {
106                                                 "mData": "platform",
107                                                 "fnRender": function (a) {
108                                                         if ( mTmp3 == 0 ) {
109                                                                 mTmp3++;
110                                                                 return "zzz3";
111                                                         } else {
112                                                                 return a.aData['platform'];
113                                                         }
114                                                 }
115                                         },
116                                         { "mData": "version" },
117                                         { "mData": "grade" }
118                                 ]
119                         } );
120                 },
121                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == 'aaa1'; }
122         );
123         
124         oTest.fnWaitTest( 
125                 "Multi-column rendering - 2nd column sorting",
126                 function () { $('#example thead th:eq(1)').click(); },
127                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'All others'; }
128         );
129         
130         oTest.fnWaitTest( 
131                 "Multi-column rendering - 3rd column sorting",
132                 function () {
133                         $('#example thead th:eq(2)').click();
134                         $('#example thead th:eq(2)').click();
135                 },
136                 function () { return $('#example tbody tr:eq(0) td:eq(2)').html() == 'zzz3'; }
137         );
138         
139         oTest.fnWaitTest( 
140                 "Multi-column rendering - 4th column sorting",
141                 function () { $('#example thead th:eq(3)').click(); },
142                 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == '-'; }
143         );
144         
145         oTest.fnWaitTest( 
146                 "Multi-column rendering - 5th column sorting",
147                 function () { $('#example thead th:eq(4)').click(); },
148                 function () { return $('#example tbody tr:eq(0) td:eq(4)').html() == 'A'; }
149         );
150         
151         
152         
153         
154         oTest.fnComplete();
155 } );