Strange happenings with footer
I apologize... I realized I posted this in the wrong forum. Should be in Using jQuery.
I am having issues with the footer of my dataTable. On the initial load it looks as desired...
![]()

BUT... if a do a reset and then another load the footer looks like this...
![]()

Note the blank area gets filled with 6.00 and the Total: with 3.00. These are actually adjacent cells from the tbody.
Here is the initialization code...
- oTable = $('#timesheet').dataTable( {
- 'bAutoWidth': false,
- 'bDestroy': true,
- 'bFilter': false,
- 'bInfo': false,
- 'bLengthChange': false,
- 'bPaginate': false,
- 'bProcessing': false,
- 'bServerSide': true,
- 'bSort': false,
- 'bVisible': true,
- 'sAjaxSource': 'files_json/get_Timesheet.php' + sParams,
-
- 'aoColumns': [
- { 'mDataProp': 'ts_ID', 'bVisible': false },
- { 'mDataProp': 'ts_Project', 'bVisible': false },
- { 'mDataProp': 'ts_Phase', 'bVisible': false },
- { 'mDataProp': 'ts_PhaseCodes','bVisible': false },
- { 'mDataProp': 'ts_cProject', 'sClass': 'udatal' },
- { 'mDataProp': 'ts_cPhase', 'sClass': 'udatal' },
- { 'mDataProp': 'ts_Mon', 'sClass': 'udatar' },
- { 'mDataProp': 'ts_Tue', 'sClass': 'udatar' },
- { 'mDataProp': 'ts_Wed', 'sClass': 'udatar' },
- { 'mDataProp': 'ts_Thr', 'sClass': 'udatar' },
- { 'mDataProp': 'ts_Fri', 'sClass': 'udatar' },
- { 'mDataProp': 'ts_Sat', 'sClass': 'udatar' },
- { 'mDataProp': 'ts_Sun', 'sClass': 'udatar' },
- { 'mDataProp': 'ts_cTotal', 'sClass': 'udatar' }
- ], // End of aoColumns
- "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
- // Calculate the sum for Mon
- var monTotal = 0.0;
- var tueTotal = 0.0;
- var wedTotal = 0.0;
- var thrTotal = 0.0;
- var friTotal = 0.0;
- var satTotal = 0.0;
- var sunTotal = 0.0;
- var totTotal = 0.0;
-
- for ( var i=0; i<aaData.length; i++ ) {
- if ( aaData[i]['ts_Mon'] == null || aaData[i]['ts_Mon'] == '' ) { monTotal += 0; } else { monTotal += parseFloat(aaData[i]['ts_Mon']); }
- if ( aaData[i]['ts_Tue'] == null || aaData[i]['ts_Tue'] == '' ) { tueTotal += 0; } else { tueTotal += parseFloat(aaData[i]['ts_Tue']); }
- if ( aaData[i]['ts_Wed'] == null || aaData[i]['ts_Wed'] == '' ) { wedTotal += 0; } else { wedTotal += parseFloat(aaData[i]['ts_Wed']); }
- if ( aaData[i]['ts_Thr'] == null || aaData[i]['ts_Thr'] == '' ) { thrTotal += 0; } else { thrTotal += parseFloat(aaData[i]['ts_Thr']); }
- if ( aaData[i]['ts_Fri'] == null || aaData[i]['ts_Fri'] == '' ) { friTotal += 0; } else { friTotal += parseFloat(aaData[i]['ts_Fri']); }
- if ( aaData[i]['ts_Sat'] == null || aaData[i]['ts_Sat'] == '' ) { satTotal += 0; } else { satTotal += parseFloat(aaData[i]['ts_Sat']); }
- if ( aaData[i]['ts_Sun'] == null || aaData[i]['ts_Sun'] == '' ) { sunTotal += 0; } else { sunTotal += parseFloat(aaData[i]['ts_Sun']); }
- if ( aaData[i]['ts_cTotal'] == null || aaData[i]['ts_cTotal'] == '' ) { totTotal += 0; } else { totTotal += parseFloat(aaData[i]['ts_cTotal']); }
- }
-
- var nCells = nRow.getElementsByTagName('th');
- // nCells[0].innerHTML = '';
- // ncells[1].innerHTML = 'Total';
- nCells[2].innerHTML = monTotal.toFixed(2);
- nCells[3].innerHTML = tueTotal.toFixed(2);
- nCells[4].innerHTML = wedTotal.toFixed(2);
- nCells[5].innerHTML = thrTotal.toFixed(2);
- nCells[6].innerHTML = friTotal.toFixed(2);
- nCells[7].innerHTML = satTotal.toFixed(2);
- nCells[8].innerHTML = sunTotal.toFixed(2);
- nCells[9].innerHTML = totTotal.toFixed(2);
- }, // End of fnFooterCallback
If I uncomment lines 24 and 25 then the table does not render at all.
Here is the table definition.
- <table id="timesheet" class="inner" border="0" cellspacing="0" cellpadding="0" width="100%">
- <thead>
- <tr>
- <th>ID</th>
- <th>Project</th>
- <th>Phase</th>
- <th>PhaseCodes</th>
- <th class="udatal" width="33%">Project-Name</th>
- <th class="udatal" width="25%">Phase-Description</th>
- <th class="udatar" width="05%">Mon</th>
- <th class="udatar" width="05%">Tue</th>
- <th class="udatar" width="05%">Wed</th>
- <th class="udatar" width="05%">Thr</th>
- <th class="udatar" width="05%">Fri</th>
- <th class="udatar" width="05%">Sat</th>
- <th class="udatar" width="05%">Sun</th>
- <th class="udatar" width="07%">Total</th>
- </tr>
- </thead>
- <tbody>
- </tbody>
- <tfoot>
- <tr class="footer">
- <th>ID</th>
- <th>Project</th>
- <th>Phase</th>
- <th>PhaseCodes</th>
- <th class="udatal" width="33%"></th>
- <th class="udatar" width="25%">Total:</th>
- <th class="udatar" width="05%"></th>
- <th class="udatar" width="05%"></th>
- <th class="udatar" width="05%"></th>
- <th class="udatar" width="05%"></th>
- <th class="udatar" width="05%"></th>
- <th class="udatar" width="05%"></th>
- <th class="udatar" width="05%"></th>
- <th class="udatar" width="07%"></th>
- </tr>
- </tfoot>
- </table>
BTW rows 13-20 of the second group is my code (I'm a newbie) for summing the column values for inclusion in the footer. If anyone has a better method please let me know.
Is this issue a bug in jQuery or am I doing something wrong. I'm betting on the latter.
TIA for any assistance.
jdadwilson