annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.fnRender.js @ 9:7300ed4c1481 draft default tip

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