Alternatif to initComplete for serverside datatable
Alternatif to initComplete for serverside datatable
blesedbeing
Posts: 4Questions: 1Answers: 0
I have code bellow to hide column if column 0 count same as total data called.
initComplete: function () {
var api = this.api();
\\ var api = table;
var totData = api.data().length;
var cCount = 6;
for (let i = 6; i <= 87; i++) {
if (i == 13 || i == 16 || i == 17 || i == 40 || i == 41 || i == 46 || i == 57 || i == 60 || i == 64 || i == 75 || i == 82 || i == 85) {
api.column(i).visible(true);
} else {
var c = api.column(i).data().filter(function (value, index) {
return value === '0' ? true : false;
}).length;
if (c == totData) {
api.column(i).visible(false);
} else {
api.column(i).visible(true);
}
}
}
}
I have tried adding the function to ajax success and to drawCallback
, there is no error message, the table only show
processing
Is there other way to perform above function?
This question has an accepted answers - jump to answer
Answers
It hides column 0 as expected here, so there's going to be something wrong with your example. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.
Cheers,
Colin
Hi colin,
yes its work fine when i am not using serverside datatable but when i did i can't seems to load the data
That shouldn't make a difference, see the same example here with server-side processing. As before, if that doesn't help, please update or link to your page so we can see,
Cheers,
Colin
Hi Colin,
Thank you for your support, its seems the function working well it just data fetched from the server was different type your answer help clear that for me.