Dynamically add Column???

Dynamically add Column???

TechRayTechRay Posts: 7Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
I am using DataTables for a project for work, for my 'proof of concept' page I had a hard-coded html table, my coworkers now have it taking JSON data from the application and I need a way to add a column of checkboxes to the table (tried with javascript sort of like insert row doesn't play nicely if you use the drop down selector to increase the row count).

I know there is a way to 'select' rows and highlight them, that is already implemented, a column of checkboxes was also asked for.

is there someway I can do dataTable.insertColumn and put check boxes in it?

Thanks!

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Currently no - DataTables has no ability to dynamically add columns after initialisation. Having said that, you can tell DataTables to have an extra column using aoColumns at initialisation time. Just define the array as long enough to add the column and use sDefaultContent to add whatever content you want.

    Allan
  • TechRayTechRay Posts: 7Questions: 0Answers: 0
    edited June 2013
    Awesome, worked perfectly, thanks!

    EDIT: Another problem has come up however, I added event listeners to the rows to change them to 'selected' in the css but it didn't work once we switched to using JSON, I added the function into the success method of the ajax call and it now works but only on the first visible page of the table.
This discussion has been closed.