HTML Table Not Converting to DataTable

HTML Table Not Converting to DataTable

aebreyaebrey Posts: 7Questions: 3Answers: 0
edited June 2019 in Free community support

I am trying to convert my HTML table into a DataTable but it is not working. I am dynamically creating my HTML table and then calling ('#example').DataTable(); and my newly created HTML table is not converting. The way my code works is you click on a button and a modal should pop-up with the table. The way I have the code written now the modal appears with just a regular HTML table. I'm not sure what I am doing wrong and why the ('#example').DataTable(); function is not working. I am using the most modern version of jQuery and DataTable files.

I have created a fiddle here to show you the html and js code I am using.You can view it here: https://jsfiddle.net/mk9ny682/1/

Thanks in advance!

Answers

  • kthorngrenkthorngren Posts: 20,315Questions: 26Answers: 4,771

    The test case isn't running. Scanning the code it looks like it should work. Hard to say without seeing it in action through.

    Kevin

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @aebrey ,

    Could you take a look at that fiddle again, please, it's not even showing a plain HTML table for me,

    Cheers,

    Colin

  • aebreyaebrey Posts: 7Questions: 3Answers: 0

    Greetings,

    Thank you for the quick responses! I re-did the fiddle (and my code). I added in a theader and now the table is displaying but it doesn't look like the css is coming through at all. I'm not sure what I am doing wrong, I'm sure it's something simple.

    Here is the udpated fiddle: https://jsfiddle.net/b9d5kp87/2/

    Thanks,
    Ashley

  • aebreyaebrey Posts: 7Questions: 3Answers: 0

    Also, you can see that the footer is messed up at the bottom of the table and it is displaying "no data available". Thanks

  • kthorngrenkthorngren Posts: 20,315Questions: 26Answers: 4,771
    edited June 2019

    You are asking the same question in this thread. Please don't duplicate threads.

    Your code isn't creating a tbody for the rows.

    Please keep the discussion to this thread.

    Kevin

This discussion has been closed.