Individual Column Searching Labels Not Showing

Individual Column Searching Labels Not Showing

heavenAdjacentheavenAdjacent Posts: 1Questions: 1Answers: 0

I checked out the example in Column Searching">API > Column Searching, but having trouble getting the var select to show a default subject label for a project I'm working on.

In the example it shows it at the footer of the example, and with blank fields. How can I make it so those fields aren't blank?

What I have tried is adding the aoColumns to the script but instead it locks the entire function of the selects into just text:

$(document).ready(function() {
    $('#postDatatable').DataTable( {
      "bLengthChange": false,
      "aoColumns": [
                null,
                { "sType": "title-string" },
                { "sType": "title-string" },
                { "sType": "title-string" },
                { "sType": "title-string" }
            ],
        initComplete: function () {
            this.api().columns().every( function () {
                var column = this;
                var select = $('<select><option value=""></option></select>')
                    .appendTo( $(column.header()).empty() )
                    .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>' )
                } );
            } );
        }
    } );
} );

What am I missing/doing wrong? Thanks for your help it means a lot.

This discussion has been closed.