1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "fnHeaderCallback" );
4 $(document).ready( function () {
5 /* Check the default */
6 var oTable = $('#example').dataTable();
7 var oSettings = oTable.fnSettings();
11 "Default should be null",
13 function () { return oSettings.fnHeaderCallback == null; }
18 "Five arguments passed",
23 $('#example').dataTable( {
24 "fnHeaderCallback": function ( ) {
25 mPass = arguments.length;
29 function () { return mPass == 5; }
34 "fnRowCallback called once per draw",
39 $('#example').dataTable( {
40 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
45 function () { return mPass == 1; }
49 "fnRowCallback called on paging (i.e. another draw)",
50 function () { $('#example_next').click(); },
51 function () { return mPass == 2; }
56 "fnRowCallback allows us to alter row information",
59 $('#example').dataTable( {
60 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
61 nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records";
65 function () { return $('#example thead th:eq(0)').html() == "Displaying 10 records"; }
70 "Data array has length matching original data",
75 $('#example').dataTable( {
76 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
77 if ( aasData.length != 57 )
84 function () { return mPass; }
88 "Data array's column lengths match original data",
93 $('#example').dataTable( {
94 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
95 for ( var i=0, iLen=aasData.length ; i<iLen ; i++ )
97 if ( aasData[i].length != 5 )
105 function () { return mPass; }
110 "iStart correct on first page",
112 oSession.fnRestore();
115 $('#example').dataTable( {
116 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
124 function () { return mPass; }
129 "iStart correct on second page",
131 oSession.fnRestore();
134 $('#example').dataTable( {
135 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
142 $('#example_next').click();
144 function () { return mPass; }
149 "iEnd correct on first page",
151 oSession.fnRestore();
154 $('#example').dataTable( {
155 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
163 function () { return mPass; }
168 "iEnd correct on second page",
170 oSession.fnRestore();
173 $('#example').dataTable( {
174 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
181 $('#example_next').click();
183 function () { return mPass; }
188 "aiDisplay length is full data when not filtered",
190 oSession.fnRestore();
193 $('#example').dataTable( {
194 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
195 if ( aiDisplay.length == 57 )
202 function () { return mPass; }
206 "aiDisplay length is 9 when filtering on 'Mozilla'",
208 oSession.fnRestore();
211 oTable = $('#example').dataTable( {
212 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
213 if ( aiDisplay.length == 9 )
219 oTable.fnFilter( "Mozilla" );
221 function () { return mPass; }