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.fnRender.js
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "aoColumns.fnRender" );
3
4 $(document).ready( function () {
5         /* Check the default */
6         var mTmp = 0;
7         var oTable = $('#example').dataTable( {
8                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
9                 "aoColumns": [
10                         { "mData": "engine" },
11                         {
12                                 "mData": "browser",
13                                 "fnRender": function (a) {
14                                         mTmp++;
15                                         return a.aData['browser'];
16                                 }
17                         },
18                         { "mData": "platform" },
19                         { "mData": "version" },
20                         { "mData": "grade" }
21                 ]
22         } );
23         var oSettings = oTable.fnSettings();
24         
25         oTest.fnWaitTest( 
26                 "Single column - fnRender is called twice for each row",
27                 null,
28                 function () { return mTmp == 57; }
29         );
30         
31         oTest.fnWaitTest( 
32                 "Confirm that fnRender passes two arguments with four parameters",
33                 function () {
34                         mTmp = true;
35                         oSession.fnRestore();
36                         oTable = $('#example').dataTable( {
37                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
38                                 "aoColumns": [
39                                         { "mData": "engine" },
40                                         { 
41                                                 "fnRender": function (a) {
42                                                         if ( arguments.length != 2 || typeof a.iDataRow=='undefined' ||
43                                                                 typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ||
44                                                                 typeof a.mData=='undefined' )
45                                                         {
46                                                                 mTmp = false;
47                                                         }
48                                                         return a.aData['browser'];
49                                                 },
50                                                 "mData": "browser"
51                                         },
52                                         { "mData": "platform" },
53                                         { "mData": "version" },
54                                         { "mData": "grade" }
55                                 ]
56                         } );
57                 },
58                 function () { return mTmp; }
59         );
60         
61         oTest.fnWaitTest( 
62                 "fnRender iDataColumn is the column",
63                 function () {
64                         mTmp = true;
65                         oSession.fnRestore();
66                         oTable = $('#example').dataTable( {
67                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
68                                 "aoColumns": [
69                                         { "mData": "engine" },
70                                         {
71                                                 "mData": "browser",
72                                                 "fnRender": function (a) {
73                                                         if ( a.iDataColumn != 1 )
74                                                         {
75                                                                 mTmp = false;
76                                                         }
77                                                         return a.aData['browser'];
78                                                 }
79                                         },
80                                         { "mData": "platform" },
81                                         { "mData": "version" },
82                                         { "mData": "grade" }
83                                 ]
84                         } );
85                 },
86                 function () { return mTmp; }
87         );
88         
89         oTest.fnWaitTest( 
90                 "fnRender aData is data array of correct size",
91                 function () {
92                         mTmp = true;
93                         oSession.fnRestore();
94                         oTable = $('#example').dataTable( {
95                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
96                                 "aoColumns": [
97                                         { "mData": "engine" },
98                                         {
99                                                 "mData": "browser",
100                                                 "fnRender": function (a) {
101                                                         if ( a.aData.length != 5 )
102                                                         {
103                                                                 mTmp = false;
104                                                         }
105                                                         return a.aData['browser'];
106                                                 }
107                                         },
108                                         { "mData": "platform" },
109                                         { "mData": "version" },
110                                         { "mData": "grade" }
111                                 ]
112                         } );
113                 },
114                 function () { return mTmp; }
115         );
116         
117         oTest.fnWaitTest( 
118                 "Passed back data is put into the DOM",
119                 function () {
120                         oSession.fnRestore();
121                         oTable = $('#example').dataTable( {
122                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
123                                 "aoColumns": [
124                                         { "mData": "engine" },
125                                         {
126                                                 "mData": "browser",
127                                                 "fnRender": function (a) {
128                                                         return 'unittest';
129                                                 }
130                                         },
131                                         { "mData": "platform" },
132                                         { "mData": "version" },
133                                         { "mData": "grade" }
134                                 ]
135                         } );
136                 },
137                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; }
138         );
139         
140         oTest.fnWaitTest( 
141                 "Passed back data is put into the DOM",
142                 function () {
143                         oSession.fnRestore();
144                         oTable = $('#example').dataTable( {
145                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
146                                 "aoColumns": [
147                                         { "mData": "engine" },
148                                         { "mData": "browser" },
149                                         { 
150                                                 "mData": "platform",
151                                                 "fnRender": function (a) {
152                                                         return 'unittest1';
153                                                 }
154                                         },
155                                         { 
156                                                 "mData": "version",
157                                                 "fnRender": function (a) {
158                                                         return 'unittest2';
159                                                 }
160                                         },
161                                         { "mData": "grade" }
162                                 ]
163                         } );
164                 },
165                 function () {
166                         var bReturn = 
167                                 $('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' &&
168                                 $('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2';
169                         return bReturn; }
170         );
171         
172         
173         
174         
175         
176         oTest.fnComplete();
177 } );