How to update columns contents?

How to update columns contents?

swautierswautier Posts: 2Questions: 0Answers: 0
edited February 2010 in General
Hi!
First of all, thanks and congratulations for dataTables. It's an outstanding piece of code!

I use Ajax (and fnAjaxReload()) to update the contents of my table. But at some moments, I also need to change the columns definition (title, width,...). Simply setting aoColumns doesn't work. How can I do?

Alternately, how can re-create the table from scratch (not simply emptying it using fnClearTable()).

TIA,

Serge.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Serge,

    To change the column titles etc you can simply use standard jQuery / DOM methods ( $('thead th:eq(0)').html('Hello'); for example). The same applies to column width. However, DataTables does not allow for adding and removing columns on the fly (other to make then hidden and show). For this you would need to nuke the old table - just remove it form the DOM, and delete the old DataTables variable (if you stored it) and create a new table.

    Regards,
    Allan
  • swautierswautier Posts: 2Questions: 0Answers: 0
    Allan,

    Thanks for your help. I decided to get rid of the table and re-create it since the amount of columns may vary some day.
This discussion has been closed.