I want to hide a column in jQuery DataTablescontaining Geo Zone in th. This is what I do:
$(document).ready(function(){
if(geo_zone_on_off==0){
var _index=$("#datatable_ajax .heading th:contains(GeoZone)").index();
var oTable=$("#datatable_ajax").DataTable();
if(_index != -1){
oTable.column(_index).visible(false);
}
}
});
A dataTable is loaded, but the column is not hidden. Before doing this, I tried to hide it when the table was processed and it worked fine. Then I did the following:
"initComplete": function(settings, json) {
if(geo_zone_on_off==0){
var _index=$("th.sorting:contains(GeoZone),th.no-sort:contains(GeoZone)").index();
if(_index != -1){
grid.getDataTable().column(_index).visible(false);
}
}
},
But he had a problem with displaying hidden columns when loading a table. To avoid this problem, I used the solution mentioned above. But it does not work, although I understand the index correctly. This does not give any errors.
source
share