How can re-initialize the columns in DataTable?
How can re-initialize the columns in DataTable?
I am working on the DataTable showing the weekly data. The headers should be added dynamically. In my case, the table header is loading properly for the first time. I am using the DateTime picker, on changing the date the DataTable should re-initialize, and the column header title should change accordingly.
The column header is not binding from the second time. on $("#table") .DataTable().ajax().reload();
Can i get any suggestion on this?
here is my code
table: {
searchDisabled: true,
url: URLS.patientDetails.reminders.getWeeklyData,
selector: adherenceReportWeekly,
columns: [
{
title: SetTableTitle(0),
data: function (row) {
return GetRowDatas(row, 0);
},
width:14
},
{
title: SetTableTitle(1),
data: function (row) {
return GetRowDatas(row, 1);
},
width:14
},
{
title: SetTableTitle(2),
data: function (row) {
return GetRowDatas(row, 2);
},
width:14
},
{
title: SetTableTitle(3),
data: function (row) {
return GetRowDatas(row, 3);
},
width:14
},
{
title: SetTableTitle(4),
data: function (row) {
return GetRowDatas(row, 4);
},
width:14
},
{
title: SetTableTitle(5),
data: function (row) {
return GetRowDatas(row, 5);
},
width:14
},
{
title: SetTableTitle(6),
data: function (row) {
return GetRowDatas(row, 6);
},
width:14
}
],
ordering: false,
pageLength: 25,
dontAddTableClass: true
},
Answers
I'm not seeing where you are reinitialising the table - could you link to a working example showing the issue please?
Allan