columnDefs not working with bStateSave = ture
columnDefs not working with bStateSave = ture
alamnaryab
Posts: 4Questions: 3Answers: 0
Hi friends
I have datetable with columnDefs
to hide few coulmns by default, it is working fine
but when I make bStateSave:true
then no coulmns are hidden
var table = $('.dt').DataTable({
orderCellsTop: true,
fixedHeader: true,
"order": [],
"pageLength": 10,
// "bStateSave":true,
// "stateSaveParams": function (settings, data) {
// data.start = 0;
// data.search.search = "";
// $.each(data.columns,function(i,v){
// //prevent column level searching
// v.search.search = "";
// });
// },
dom:"<'row'<'col-sm-3'l><'col-sm-6 text-center'B><'col-sm-3'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
"columnDefs": [
{ "visible": false, "targets": 1 },
{ "visible": false, "targets": 2 },
{ "visible": false, "targets": 3 },
{ "visible": false, "targets": 4 },
],
This question has an accepted answers - jump to answer
Answers
It seems to be working as expected here. 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
Sounds like the state was saved with the columns visible. You can use
stateLoadParams
to removed the columns from being loaded so thecolumnDefs
are applied.Kevin