Add table columns dynamically

Add table columns dynamically

soulbriskisoulbriski Posts: 21Questions: 7Answers: 0

Is it possible to add further columns to an already initilized table?

Something like table.columns.add({data:newData, title:newTitle})

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    edited December 2022

    No, there is not a way to dynamically add columns to an initialized table. To change most Datatables options you will need to destroy() the Datatable then reinitialize with the new options.

    Depending on your requirements it might be possible to hide the column with columns.visible then display it later with the new data that you add using cell().data() or row().data().

    Kevin

Sign In or Register to comment.