Get column name

Get column name

PopeyePopeye Posts: 1Questions: 0Answers: 0
edited March 2017 in Free community support

Hi, I would like to add name of the column in label.

$(document).ready(function() {
$('#example1').DataTable( {
"order": [[ 0, "desc" ]],
initComplete: function () {
this.api().columns('.select-filter').every( function () {
var column = this;
var select = $('<select class="form-control input-sm"><option value="">All</option></select>')
.appendTo( 'div.dataTables_length' )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );

            column.data().unique().sort().each( function ( d, j ) {
                select.append( '<option value="'+d+'">'+d+'</option>' )  
            } );         
             select.wrap( '<label> Filter: </label>' )                                
        } );             
    }

} );

} );

This discussion has been closed.