Datatable dropdown filters are not being displayed

Datatable dropdown filters are not being displayed

michaelchikmichaelchik Posts: 2Questions: 1Answers: 0
edited November 2019 in Free community support

I am trying to display the datatable with dropdown column filters described hear https://datatables.net/examples/api/multi_filter_select.html Although the plugin obviously works since I can see pagination, search field and other common features of DT I still don't see the dropdowns.

$(document).ready(function () {
                $('#myselector').DataTable({
                    initComplete: function () {
                        this.api().columns().every(function () {
                            var column = this;
                            var select = $('<select><option value=""></option></select>')
                                .appendTo($(column.footer()).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>')
                            });
                        });
                    }
                });
            });

Edited by Kevin:  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

This discussion has been closed.