Mercurial > repos > saskia-hiltemann > ireport
comparison DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/fnHeaderCallback.js @ 0:ac5f9272033b draft
first upload
author | saskia-hiltemann |
---|---|
date | Tue, 01 Jul 2014 11:42:23 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ac5f9272033b |
---|---|
1 // DATA_TEMPLATE: empty_table | |
2 oTest.fnStart( "fnHeaderCallback" ); | |
3 | |
4 $(document).ready( function () { | |
5 /* Check the default */ | |
6 var oTable = $('#example').dataTable( { | |
7 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
8 "bDeferRender": true | |
9 } ); | |
10 var oSettings = oTable.fnSettings(); | |
11 var mPass, bInit; | |
12 | |
13 oTest.fnWaitTest( | |
14 "Default should be null", | |
15 null, | |
16 function () { return oSettings.fnHeaderCallback == null; } | |
17 ); | |
18 | |
19 | |
20 oTest.fnWaitTest( | |
21 "Five arguments passed", | |
22 function () { | |
23 oSession.fnRestore(); | |
24 | |
25 mPass = -1; | |
26 bInit = false; | |
27 $('#example').dataTable( { | |
28 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
29 "bDeferRender": true, | |
30 "fnHeaderCallback": function ( ) { | |
31 mPass = arguments.length; | |
32 }, | |
33 "fnInitComplete": function () { | |
34 bInit = true; | |
35 } | |
36 } ); | |
37 }, | |
38 function () { return mPass == 5 && bInit; } | |
39 ); | |
40 | |
41 | |
42 /* The header callback is called once for the init and then when the data is added */ | |
43 oTest.fnWaitTest( | |
44 "fnHeaderCallback called once per draw", | |
45 function () { | |
46 oSession.fnRestore(); | |
47 | |
48 mPass = 0; | |
49 bInit = false; | |
50 $('#example').dataTable( { | |
51 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
52 "bDeferRender": true, | |
53 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
54 mPass++; | |
55 }, | |
56 "fnInitComplete": function () { | |
57 bInit = true; | |
58 } | |
59 } ); | |
60 }, | |
61 function () { return mPass == 2 && bInit; } | |
62 ); | |
63 | |
64 oTest.fnWaitTest( | |
65 "fnRowCallback called on paging (i.e. another draw)", | |
66 function () { $('#example_next').click(); }, | |
67 function () { return mPass == 3; } | |
68 ); | |
69 | |
70 | |
71 oTest.fnWaitTest( | |
72 "fnRowCallback allows us to alter row information", | |
73 function () { | |
74 oSession.fnRestore(); | |
75 $('#example').dataTable( { | |
76 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
77 "bDeferRender": true, | |
78 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
79 nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records"; | |
80 } | |
81 } ); | |
82 }, | |
83 function () { return $('#example thead th:eq(0)').html() == "Displaying 10 records"; } | |
84 ); | |
85 | |
86 | |
87 oTest.fnWaitTest( | |
88 "iStart correct on first page", | |
89 function () { | |
90 oSession.fnRestore(); | |
91 | |
92 mPass = true; | |
93 $('#example').dataTable( { | |
94 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
95 "bDeferRender": true, | |
96 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
97 if ( iStart != 0 ) | |
98 { | |
99 mPass = false; | |
100 } | |
101 } | |
102 } ); | |
103 }, | |
104 function () { return mPass; } | |
105 ); | |
106 | |
107 | |
108 oTest.fnWaitTest( | |
109 "iStart correct on second page", | |
110 function () { | |
111 oSession.fnRestore(); | |
112 | |
113 mPass = false; | |
114 $('#example').dataTable( { | |
115 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
116 "bDeferRender": true, | |
117 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
118 if ( iStart == 10 ) | |
119 { | |
120 mPass = true; | |
121 } | |
122 }, | |
123 "fnInitComplete": function () { | |
124 $('#example_next').click(); | |
125 } | |
126 } ); | |
127 }, | |
128 function () { return mPass; } | |
129 ); | |
130 | |
131 | |
132 oTest.fnWaitTest( | |
133 "iEnd correct on second page", | |
134 function () { | |
135 oSession.fnRestore(); | |
136 | |
137 mPass = false; | |
138 $('#example').dataTable( { | |
139 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
140 "bDeferRender": true, | |
141 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
142 if ( iEnd == 20 ) | |
143 { | |
144 mPass = true; | |
145 } | |
146 }, | |
147 "fnInitComplete": function () { | |
148 $('#example_next').click(); | |
149 } | |
150 } ); | |
151 }, | |
152 function () { return mPass; } | |
153 ); | |
154 | |
155 | |
156 oTest.fnWaitTest( | |
157 "aiDisplay length is full data when not filtered", | |
158 function () { | |
159 oSession.fnRestore(); | |
160 | |
161 mPass = false; | |
162 $('#example').dataTable( { | |
163 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
164 "bDeferRender": true, | |
165 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
166 if ( aiDisplay.length == 57 ) | |
167 { | |
168 mPass = true; | |
169 } | |
170 } | |
171 } ); | |
172 }, | |
173 function () { return mPass; } | |
174 ); | |
175 | |
176 oTest.fnWaitTest( | |
177 "aiDisplay length is 9 when filtering on 'Mozilla'", | |
178 function () { | |
179 oSession.fnRestore(); | |
180 | |
181 mPass = false; | |
182 oTable = $('#example').dataTable( { | |
183 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
184 "bDeferRender": true, | |
185 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) { | |
186 if ( aiDisplay.length == 9 ) | |
187 { | |
188 mPass = true; | |
189 } | |
190 } | |
191 } ); | |
192 oTable.fnFilter( "Mozilla" ); | |
193 }, | |
194 function () { return mPass; } | |
195 ); | |
196 | |
197 | |
198 | |
199 oTest.fnComplete(); | |
200 } ); |