0

I'm using the following code to add filtering on one column in my datatable:

"initComplete": function () {
                this.api().column(4).every( function () {
                    var column = this;
                    var select = jQuery('<select><option value=""></option></select>')
                    .appendTo( jQuery(column.header()).empty() )
                    .on( 'change', function () {
                        var val = jQuery.fn.dataTable.util.escapeRegex(
                            jQuery(this).val()
                        );

                        column
                            .search( val ? '^'+val+'$' : '', true, false )
                            .draw();
                    });

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

I was wondering 1) if there is a way to add an 'All' option to the filter rather than just the blank filter selection option and 2) if there is a way to add a label to the left of the filter dropdown, e.g., Type?

Thanks!

1 Answer 1

0

Found answer to part 1 - replace the "" with "All":

<select><option value="All"></option></select>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .