column-visibility function question

column-visibility function question

duckdown2017duckdown2017 Posts: 6Questions: 2Answers: 0
edited December 2020 in Free community support

I have a script that returns the column number or index when I use the built in pop-up with buttons to show/hide columns. Is there a way when I use column-visibility from the built in buttons to get the column header name. Here is the script I am using that retuns the col numbers that I send to a web service to update a datrabase.

var table = $('#example').DataTable({.....

table.on('column-visibility.dt', function (e, settings, column, state) {
     var colchanged = column.toString() + ',' + state.toString();
     $.ajax({
         url: '/Shared/WebServiceHandler.ashx?q=GetDataTable3&s=' + colchanged ,
         dataType: 'json',
         type: 'POST',
         success: function () {}                 
     });
});

Regards
Michael Duclon

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    I think the way you're doing is probably best. You could over-write the action of the visibility button but I suspect that'll be fiddlier,

    Colin

  • duckdown2017duckdown2017 Posts: 6Questions: 2Answers: 0

    Thanks Colin, I've come up with a work around.

This discussion has been closed.