how to refresh table after adding columns
how to refresh table after adding columns
ziv@kpmbro.com
Posts: 73Questions: 28Answers: 4
Hi Allan .
I am adding/removing columns from my table (based on user action), and now i want to refresh my table so it will fit the new rows data. (come from the server side).
code some thing like this:
var table = $('#example').DataTable( {
ajax: {
url: "view_stats/make_stats_test",
data: {
"get_fields":false
}
,
type: 'POST'
},
"columns": [
{ "data": "profit_margin" },
{ "data": "ctr" }
],
"order": [[1, 'asc']]
} );
and now i am changing it to this (i also change the json data accordingly )
var table = $('#example').DataTable( {
ajax: {
url: "view_stats/make_stats_test",
data: {
"get_fields":false
}
,
type: 'POST'
},
"columns": [
{ "data": "profit_margin" },
{ "data": "ctr" },
{ "data": "cost" }
],
"order": [[1, 'asc']]
} );
is it even possible to "inject" a new column and then redraw the table?
what is the best way to refresh it?
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You need to destroy a table (
destroy()
) before you can add or remove columns.Allan
Thanks Allan