DataTables applies formatting to my dynamically template-generated table but "sees" 0 (zero) rows?

DataTables applies formatting to my dynamically template-generated table but "sees" 0 (zero) rows?

homerjuliohomerjulio Posts: 6Questions: 1Answers: 0

I'm using WordPress; on a page I am linking to mysql on my localhost from a php template that queries the data. The table is displayed with all existing rows. DataTables applies it's basic formatting successfully but at it's footer states "Showing 1 to 1 of 1 entries" so -of course, there's no sorting or data search produced.

This is the simple DataTables call I have at the bottom of the template:

$(document).ready(function() {     $('#SelectRecsTable').dataTable( { "bJQueryUI": true, "paging":   true,         "ordering": true,         "info":     true     } ); } );

Dunno how to enable datatables to "see" the rows info that is actually being displayed. I am using <?php echo $print->Identificacion; ?> to output the data as an example for the "Identification" column (which again, shows!)

Heeeelp will be much appreciated! :D

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    Answer ✓

    Sounds like your table is an HTML based table, correct? This doc explain data sources supports:
    https://datatables.net/manual/data/#Data-sources

    Here is an example of an HTML based table:
    https://datatables.net/examples/basic_init/zero_configuration.html

    If yours is HTML sourced then it is likely that there is something with the way the table is built that Datatables doesn't support or like. Could by improper HTML or using rowspan or colspan in the tbody which DT doesn't support.

    Kevin

  • homerjuliohomerjulio Posts: 6Questions: 1Answers: 0

    Never mind Forum community! Silly mistake; my bad! Inside my <?php foreach ($result as $print) { ?> loop, I placed the <tbody> tag so my table had a zillion <tbody> tags therefore TableData ignored the data (for it's obviously improper table format)

    I'll leave this here for it might be of help for somebody else.. one day.. in the foreseeable future B)

  • homerjuliohomerjulio Posts: 6Questions: 1Answers: 0

    kthorngren Thank you so much for your prompt response! :) You hit it right on the nail.

This discussion has been closed.