Problem Grand Total in Footer
Problem Grand Total in Footer
VAILLY Olivier
Posts: 19Questions: 0Answers: 0
Hi,
i'm trying to make a footerCallBack from the sample in this site
On loading page, Firebug say me : "TypeError: reduce of empty array with no initial value"
I check my code, all is conform
just a point, my data comes from a php script with JSON and all is ok without the footercallback !
Any idea ?
Thanks
Oliver
This discussion has been closed.
Replies
Can you atleast give us anything for debugging?.. :-P
The js code? or a JSBin instance? Or a link to the site? etc etc.
Didnt really give us much to go on to help you
Oups sorry you are right, i'm confused !
Tomorow i'll post my code ...
So to resume :
1) one file for HTML design with table
2) a JS file for dataTable and Editor declaration
3) a PHP file for data retreiving from Postgresql bdd via AJAX
My JS file :
3) My php file :
Thanks for yoour help :)
Oliver
Hi Oliver,
Thanks for the code. Change:
to be:
Why? As the error suggests the array is empty on the first run (because there is no data int he table until it has been loaded).
reduce()
can't operate on just an empty array, so you need to give it a default. I'll update my footer example to include that!Allan
great Allan ! thanks !
I was running around such solution but with a test on data.length variable but your code is much more serious !
:)
Oliver