Adding columns to empty table

Adding columns to empty table

DawissDawiss Posts: 2Questions: 1Answers: 0
edited July 2014 in Free community support

Is it possible to dynamically add columns to empty table, no columns in thead, in 1.10 version?

Answers

  • rhinorhino Posts: 80Questions: 2Answers: 17
    edited July 2014

    You can do this with jQuery:

    var table = $('#myTable');
    
    addColumn(table, 'Name');
    addColumn(table, 'Address');
    addColumn(table, 'Phone');
    
    //Note! Assumes that you have a single row
    //     in your thead.
    function addColumn( table, title
    {
        table.find('thead tr').append('<th>' + title + '</th>');
    }
    
  • DawissDawiss Posts: 2Questions: 1Answers: 0

    Thank you rhino for the answer, but I was interested if it's possible using Datatable 1.10 API or datatables options?

  • rhinorhino Posts: 80Questions: 2Answers: 17

    AFAIK, DataTables has no built-in support for adding columns

This discussion has been closed.