- This topic has 4 replies, 2 voices, and was last updated 5 years, 5 months ago by
Support. This post has been viewed 4552 times
-
AuthorPosts
-
February 4, 2021 at 8:40 pm #10035980
Naresh Designs
ParticipantHi Team ,
Could you please help me for show/hide columns with checkbox on Editable Tables , find below my code
HTML:
<label>
<input type=”checkbox” class=”hide_show” value=””>
Show Users Column
</label>JS(examples.datatables.editable):
dom: ‘<“row”<“col-lg-6″l><“col-lg-6″f>><“table-responsive”t>p’,
aoColumns: [null, null, null, null, { bSortable: false }],
buttons: [{
extend: ‘colvis’,
columns: ‘:not(:first-child)’
}
]I tried the below links
https://datatables.net/release-datatables/extensions/ColVis/examples/simple.htmlhttps://datatables.net/examples/api/show_hide.html
February 4, 2021 at 11:58 pm #10035986Support
KeymasterHello,
First use this HTML for the checkbox:
<input type="checkbox" class="hide_show" value="0"> Show Users Column </label>* The
valueattribute represents the column index. For example if you want the second column, the value should bevalue="1".Then, add the code below at (js/custom.js):
$('.hide_show').on('change', function(){ // Get the column API object var column = $('#datatable-editable').DataTable().column( $(this).val() ); // Toggle the visibility column.visible( ! column.visible() ); });Please try that and let us know if you need further assistance.
Kind Regards,
Rodrigo.
If you are satisfied with Porto Admin and our support, please leave your comment and rating on ThemeForest downloads page. That helps us a lot: https://themeforest.net/downloads
February 5, 2021 at 12:42 am #10035989Naresh Designs
ParticipantThank you for your reply..
As you suggested I have added code on the respective HTML and custom js page, When the check box checked column hiding fine after that when I trying to download PDF .that not working getting below error
here is image:

HTML: <label><input type=”checkbox” class=”hide_show” value=”3″>Show Users Column</label>
Custom JS: $(“.hide_show”).on(“change”, function () {
// Get the column API object
var column = $(“#datatable-editable”).DataTable().column($(this).val());// Toggle the visibility
column.visible(!column.visible());
});
February 5, 2021 at 1:01 am #10035991Naresh Designs
ParticipantI am looking at data tables that show hide columns using the checkbox with PDF download
February 5, 2021 at 6:26 am #10035997Support
KeymasterHello,
This issue seems to be a limitation of DataTables + PDF Button and the Toggle Column custom code. Unfortunately we don’t have a solution for that. Please note that DataTables is a third party plugin we include with Porto Admin, this mean it’s not a code created from zero by us.
We did a try redrawing the table when toggle the columns, but without success. This seems to be a limitation as mentioned above.
We hope you understand!
Let us know if you need any further help.
Kind Regards,
Rodrigo.
-
AuthorPosts
This topic is marked as "RESOLVED" and can not rceive new replies.