I have a table that hides and teaches columns depending on a parameter that happened to it, everything goes well until I implement the vertical scroll and I get the following error: Can not read property 'style' of undefined. IN other functions I do not hide the column, I do not receive errors I tried to make a demonstrable example but I have not known, I'm trying to do it.
function busProyectosNtactil() {
if ($("#chkOf").prop('checked')) {
interruptor = '1';
} else {
interruptor = '0';
}
if ($("#prsp").prop('checked')) {
prsp = '1';
} else {
prsp = '0';
}
var parametros = {
"interruptor": interruptor,
"prsp": prsp
};
tblProyectosNtactil = $('#tbl_ProyectosTactil').DataTable({
scrollY: '35vh',
"scrollCollapse": true,
"scrollX": false,
"bLengthChange": false,
"bPaginate": true,
"bInfo": false,
"searching": true,
"autoWidth": false,
"responsive": true,
"destroy": "true",
"ajax": {
"data": parametros,
"url": "php/tos.php",
"type": "POST",
"dataSrc": "",
},
"columns": [ {
"data": "id"
}, {
"data": "prio" ,"responsivePriority": "9"
}, {
"data": "eje"
},{
"data": "cta_id"
},{
"data": 'emp',
render: function (data, type, row) {
emp = devuelveEmpresa(data)
return emp;
}
},{
"data": "nombre_seguimiento" ,"responsivePriority": "8"
}, {
"data": "name" ,"responsivePriority": "3"
}, {
"data": "dsc"
}, {
"data": "nombre_director"
}, {
"data": "nombre_responsable"
}, {
"data": "nombre_grupo"
}, {
"data": "prsp_acu_tot" ,"responsivePriority": "4"
},{
"data": "prsp_sol"
},{
"data": "fch_fin_prevista" ,"responsivePriority": "5"
}, ],
});
//Esto es lo que me provoca el error.
if(prsp==1){
tblProyectosNtactil.columns( [0,1,5,8,10,11,13] ).visible( false );
tblProyectosNtactil.columns( [2,3,4] ).visible( true );
}
else if(prsp==0)
{
tblProyectosNtactil.columns( [1,5,8,10,11,13] ).visible( true );
tblProyectosNtactil.columns( [0,2,3,4] ).visible( false );
}
});
}