1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "fnHeaderCallback" );
4 $(document).ready( function () {
5 /* Check the default */
6 var oTable = $('#example').dataTable( {
8 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php"
10 var oSettings = oTable.fnSettings();
14 "Default should be null",
16 function () { return oSettings.fnHeaderCallback == null; }
21 "Five arguments passed",
26 $('#example').dataTable( {
28 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
29 "fnHeaderCallback": function ( ) {
30 mPass = arguments.length;
34 function () { return mPass == 5; }
39 "fnRowCallback called once per draw",
44 $('#example').dataTable( {
46 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
47 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
52 function () { return mPass == 1; }
56 "fnRowCallback called on paging (i.e. another draw)",
57 function () { $('#example_next').click(); },
58 function () { return mPass == 2; }
63 "fnRowCallback allows us to alter row information",
66 $('#example').dataTable( {
68 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
69 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
70 nHead.getElementsByTagName('th')[0].innerHTML = "Displaying "+(iEnd-iStart)+" records";
74 function () { return $('#example thead th:eq(0)').html() == "Displaying 10 records"; }
79 "iStart correct on first page",
84 $('#example').dataTable( {
86 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
87 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
95 function () { return mPass; }
100 "iStart correct on second page",
102 oSession.fnRestore();
105 $('#example').dataTable( {
107 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
108 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
114 "fnInitComplete": function () {
115 $('#example_next').click();
119 function () { return mPass; }
124 "iEnd correct on second page",
126 oSession.fnRestore();
129 $('#example').dataTable( {
131 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
132 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
138 "fnInitComplete": function () {
139 $('#example_next').click();
143 function () { return mPass; }
148 "aiDisplay length is full data when not filtered",
150 oSession.fnRestore();
153 $('#example').dataTable( {
155 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
156 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
157 if ( aiDisplay.length == 10 )
164 function () { return mPass; }
168 "aiDisplay length is 9 when filtering on 'Mozilla'",
170 oSession.fnRestore();
173 oTable = $('#example').dataTable( {
175 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
176 "fnHeaderCallback": function ( nHead, aasData, iStart, iEnd, aiDisplay ) {
177 if ( aiDisplay.length == 9 )
183 oTable.fnFilter( "Mozilla" );
185 function () { return mPass; }