I am unable to hide the columns in my datatables.
I am unable to hide the columns in my datatables.
sedategoofi
Posts: 6Questions: 4Answers: 0
I want to invisible certain columns in my datatable. but its not working, my code is as below
$(document).ready(function () {
$("#datatablecms_mem").DataTable({
order: [[1, "desc"]],
columnDefs: [
{
target: 3,
visible: false,
},
],
language: {
paginate: {
previous: "<i class='mdi mdi-chevron-left'>",
next: "<i class='mdi mdi-chevron-right'>",
},
},
drawCallback: function () {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded");
},
});
var a = $("#datatable-buttons").DataTable({
lengthChange: !1,
language: {
paginate: {
previous: "<i class='mdi mdi-chevron-left'>",
next: "<i class='mdi mdi-chevron-right'>",
},
},
drawCallback: function () {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded");
},
buttons: ["copy", "excel", "pdf", "colvis"],
});
a
.buttons()
.container()
.appendTo("#datatable-buttons_wrapper .col-md-6:eq(0)"),
$(".dataTables_length select").addClass("form-select form-select-sm"),
$("#selection-datatable").DataTable({
select: { style: "multi" },
language: {
paginate: {
previous: "<i class='mdi mdi-chevron-left'>",
next: "<i class='mdi mdi-chevron-right'>",
},
},
drawCallback: function () {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded");
},
}),
$("#key-datatable").DataTable({
keys: !0,
language: {
paginate: {
previous: "<i class='mdi mdi-chevron-left'>",
next: "<i class='mdi mdi-chevron-right'>",
},
},
drawCallback: function () {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded");
},
}),
a
.buttons()
.container()
.appendTo("#datatable-buttons_wrapper .col-md-6:eq(0)"),
$(".dataTables_length select").addClass("form-select form-select-sm"),
$("#alternative-page-datatable").DataTable({
pagingType: "full_numbers",
drawCallback: function () {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded"),
$(".dataTables_length select").addClass("form-select form-select-sm");
},
}),
$("#scroll-vertical-datatable").DataTable({
scrollY: "350px",
scrollCollapse: !0,
paging: !1,
language: {
paginate: {
previous: "<i class='mdi mdi-chevron-left'>",
next: "<i class='mdi mdi-chevron-right'>",
},
},
drawCallback: function () {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded");
},
}),
$("#complex-header-datatable").DataTable({
language: {
paginate: {
previous: "<i class='mdi mdi-chevron-left'>",
next: "<i class='mdi mdi-chevron-right'>",
},
},
drawCallback: function () {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded"),
$(".dataTables_length select").addClass("form-select form-select-sm");
},
columnDefs: [{ visible: !1, targets: -1 }],
}),
$("#state-saving-datatable").DataTable({
stateSave: !0,
language: {
paginate: {
previous: "<i class='mdi mdi-chevron-left'>",
next: "<i class='mdi mdi-chevron-right'>",
},
},
drawCallback: function () {
$(".dataTables_paginate > .pagination").addClass("pagination-rounded"),
$(".dataTables_length select").addClass("form-select form-select-sm");
},
});
});
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
Can you link to a test case showing the issue please?
Allan
Please find test page for reference
https://cms.palacevillas.com/test.php
You are using
columnDefs.target
which was introduced in Datatables 1.12. You are using Datatables 1.10.23 which doesn't have this option. UsecolunDefs.targets
, with ans
, instead.Kevin
Is there any way my CSS work with this old datatable version?
With simple datatable CSS command works
I'm not sure what you are asking. Please update the test case to show the issue and provide details of what the problem is.
Kevin