How can I have a footer generated when using AJAX/JSON data?

How can I have a footer generated when using AJAX/JSON data?

cyboratcyborat Posts: 2Questions: 1Answers: 0
edited October 2014 in Free community support

Hi - well, I've been searching around for awhile now and still haven't found what I'm looking for (cue U2).

I have a UI where I'm building reports that pop into dataTable instances based on JSON data. All of that is working great, but now I want to be able to have a footer generated for me so that I can make a summary row. What I'm doing is creating an empty $("<table>") object (though I also add IDs and such to it), adding it to the DOM, then doing the dataTable call on it using column defs, and populating it with the JSON data. That is all working great, generating the table dynamically like I want, but it doesn't create a <tfoot> for me. I tried to add the tfoot element to the instantiation of the new table: $("<table><tfoot></tfoot></table>") (or similar), but once it all renders out there's no <tfoot> to be found.

Am I going about this wrong? I was planning to then use fnFooterCallback to go through and render out the sum values into the cells. But since there's no footer element there, it doesn't do anything.

Thanks in advance for any feedback, and if I'm missing something blatant, I'll be happy to be the first to facepalm....

Answers

  • allanallan Posts: 63,386Questions: 1Answers: 10,449 Site admin

    Interesting that there is no tfoot if you include it - that should work - as shown in this example (it is empty - but present). Can you link to a test case showing the issue please?

    There is no ability in DataTables core for it to construct a footer - you need to built it using DOM methods if you want one.

    Allan

  • cyboratcyborat Posts: 2Questions: 1Answers: 0

    Well by-golly - it IS there, when I do it right haha! I was adding the tfoot to my bit of code that was building SUB tables but I hadn't put it in the main one. D'OH! double facepalm

    Thanks allan - if you hadn't responded I'd probably have continued going in circles. Really appreciate it!

    Now I've got to see if I can get totals for row groups. Anyone have success there? I'm wanting a total row for each group....

  • allanallan Posts: 63,386Questions: 1Answers: 10,449 Site admin

    Heh - so it goes...

    How are you drawing the footer for your row groups?

    Allan

This discussion has been closed.