jeditable and fnFooterCallback (Solution)

jeditable and fnFooterCallback (Solution)

AKM3AKM3 Posts: 9Questions: 0Answers: 0
edited November 2013 in General
Dear readers,
I had the same issue about using jeditable and a totals footer refresh as described here:
http://datatables.net/forums/discussion/comment/26898

And as I found a solution, wanted to share it with the list here, to keep it up with the spirit of community sharing our findings.

Basically, the only way I found to do a refresh is not with a fnDraw, but a with a complete creation of the table. Jeditable is an external plugin AFAIK, and it's not easy to deal with it. For example, trying to do a console.log( aaData[i][ourNumberColumn] ) in the fnFooterCallback right after the cell update, will bring the tags into the console. And thus, a Nan in our footer column.

So the only true solution that I've found is doing the following :
[code]

// Declare table as a global
var otableadv;

// Initial jeditable declaration
qtyEditable = {
mData: 'quantity',
type: 'number',placeholder: '',submit: 'Save', event: 'click',
width: '2em',
sUpdateURL: ajaxurl,
"callback": function( sValue, x) {

// Completely redraw table on jeditable callback
drawtable();
}
};

/* drawtable function that is called when $(document).ready

Notice it has the "bDestroy":true added, so it will destroy old object before starting again
*/
function drawtable() {
otableadv=$('#adv').dataTable({
"sDom": 'Trt<"dataTables_paginate">p',
"iDisplayLength": 50,
"sPaginationType": "full_numbers",
"oLanguage": {
"sEmptyTable": "No Keywords submitted."
},
"bDestroy":true,

"fnFooterCallback":
function ( nRow, aaData, iStart, iEnd, aiDisplay ) {


var iTotal = 0;
for ( var i=0 ; i
This discussion has been closed.