How do I achieve the old colvis fnLabel()?

How do I achieve the old colvis fnLabel()?

sebastienbarresebastienbarre Posts: 24Questions: 1Answers: 0
edited October 2016 in Free community support

Upgrading to 1.10, and I have a tough time finding a way to replace the old colvis fnLabel().
I need a callback to dynamically create each button name.
The new implementation is pretty opaque:

    _columnText: function ( dt, col ) {
            // Use DataTables' internal data structure until this is presented
            // is a public API. The other option is to use
            // `$( column(col).node() ).text()` but the node might not have been
            // populated when Buttons is constructed.
            var idx = dt.column( col ).index();
            return dt.settings()[0].aoColumns[ idx ].sTitle
                .replace(/\n/g," ")        // remove new lines
                .replace( /<.*?>/g, "" )   // strip HTML
                .replace(/^\s+|\s+$/g,""); // trim

Here is the old API:

    $('#example').dataTable( {
        "sDom": 'C<"clear">lfrtip',
        "oColVis": {
          "fnLabel": function ( index, title, th ) {
            return (index+1) +'. '+ title;
          }
        }
    } );

Leveraging this callback, I used to be able to reach in the th and grab a data-full-name attribute I had placed there for this purpose.

fnLabelCallback = function (index, title, th) {
   return $(th).attr('data-full-name') || title || ('Column #' + (index + 1));
};

Any suggestion?
Thanks

This discussion has been closed.