1 // DATA_TEMPLATE: js_data
2 oTest.fnStart( "fnFooterCallback" );
4 $(document).ready( function () {
5 /* Check the default */
6 var oTable = $('#example').dataTable( {
9 var oSettings = oTable.fnSettings();
13 "Default should be null",
15 function () { return oSettings.fnFooterCallback == null; }
20 "Five arguments passed",
25 $('#example').dataTable( {
27 "fnFooterCallback": function ( ) {
28 mPass = arguments.length;
32 function () { return mPass == 5; }
37 "fnRowCallback called once per draw",
42 $('#example').dataTable( {
44 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
49 function () { return mPass == 1; }
53 "fnRowCallback called on paging (i.e. another draw)",
54 function () { $('#example_next').click(); },
55 function () { return mPass == 2; }
60 "fnRowCallback allows us to alter row information",
63 $('#example').dataTable( {
65 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
66 nFoot.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records";
70 function () { return $('#example tfoot th:eq(0)').html() == "Displaying 10 records"; }
75 "Data array has length matching original data",
80 $('#example').dataTable( {
82 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
83 if ( aasData.length != 57 )
90 function () { return mPass; }
94 "Data array's column lengths match original data",
99 $('#example').dataTable( {
101 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
102 for ( var i=0, iLen=aasData.length ; i<iLen ; i++ )
104 if ( aasData[i].length != 5 )
112 function () { return mPass; }
117 "iStart correct on first page",
119 oSession.fnRestore();
122 $('#example').dataTable( {
124 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
132 function () { return mPass; }
137 "iStart correct on second page",
139 oSession.fnRestore();
142 $('#example').dataTable( {
144 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
151 $('#example_next').click();
153 function () { return mPass; }
158 "iEnd correct on first page",
160 oSession.fnRestore();
163 $('#example').dataTable( {
165 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
173 function () { return mPass; }
178 "iEnd correct on second page",
180 oSession.fnRestore();
183 $('#example').dataTable( {
185 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
192 $('#example_next').click();
194 function () { return mPass; }
199 "aiDisplay length is full data when not filtered",
201 oSession.fnRestore();
204 $('#example').dataTable( {
206 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
207 if ( aiDisplay.length == 57 )
214 function () { return mPass; }
218 "aiDisplay length is 9 when filtering on 'Mozilla'",
220 oSession.fnRestore();
223 oTable = $('#example').dataTable( {
225 "fnFooterCallback": function ( nFoot, aasData, iStart, iEnd, aiDisplay ) {
226 if ( aiDisplay.length == 9 )
232 oTable.fnFilter( "Mozilla" );
234 function () { return mPass; }