DataTables add column dynamically to table

后端 未结 4 1821
星月不相逢
星月不相逢 2021-02-09 03:07

I\'m using DataTables (datatables.net) to display data from an Ajax source and having trouble customizing it. One thing I would like to do is add a column so I can have for exam

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-09 03:32

    Had the same problem a few months back. This is what I did.
    By no means an elegant slution, but this worked.

    As you might already know, DataTables do have an overload to accept Javascript Arrays.

    So I made by $.ajax call. got my json, parsed it to a javascript array and then while parsing I created an extra element (an anchor tag) with href="edit.php?email=passed_email" Then on the column headers and added a column called Edit. Those values were fed to "aaData" and "aoColumns". And then the table was populated.

    And BTW, if you looking for inline editing, check the following link.
    DataTables editing example - with jEditableplugin

提交回复
热议问题