Add custom text and/or fields to table info

Add custom text and/or fields to table info

GerardoGerardo Posts: 66Questions: 0Answers: 0
edited August 2010 in General
Case in point:

I have some memcached data I want to present in a table.
Took care of passing last_updated and time_to_live.

[code]
$.getJSON("ranks.php", query_args, function(json) {
$("#points").dataTable( {
...........................................................................
last_updated: json.last_updated,
time_to_live: json.time_to_live
} );
[/code]

Is there a way to put this info in the table (not in a field, in a header/footer)?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    There certainly is - just use standard DOM methods (or jQuery...):

    [code]
    $('#points tfoot>tr td:eq(0)').html( json.last_updated );
    [/code]
    For example.

    Allan
  • GerardoGerardo Posts: 66Questions: 0Answers: 0
    Thanks, Allan!

    Worked fine, once I added a tfoot (is there a way to add one using jQuery?)

    Gerardo
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    You can add a table footer using insertAfter, or any other DOM manipulation method jQuery provides. Or you can change the selector to insert the information into the header. Whichever you prefer :-)

    Allan
  • GerardoGerardo Posts: 66Questions: 0Answers: 0
    hmm, just below this comment:

    [code]
    /*
    * Final init
    * Sanity check that there is a thead and tfoot. If not let's just create them
    */
    [/code]

    thead and tbody are created if not existant, but tfoot is not. Maybe you meant tbody instead?

    Thanks,
    Gerardo
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I did indeed - thanks for pointing that out.

    Allan
This discussion has been closed.