datatable column filter shows no matching records found

datatable column filter shows no matching records found

tarunataruna Posts: 1Questions: 1Answers: 0

initComplete: function () {
this.api().columns('.select-filter').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>')
            });
        });

It displays the select boxes with values but doesn't search on selected values,

also the filter boxes shows the column data as column1 data "> column1 data, suppose to be just column1 data, I am using chrome. Doesn't show unique values, shows up all the data.

<option value="<text id=" rowname0"="">Admin Admin">Admin Admin</option>

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    edited October 2017

    I built a test case for you by copying your code here:
    http://live.datatables.net/ficofosu/1/edit

    In the future please use Markdown to format your code. It will be much easier to read.

    For simplicity I removed '.select-filter' from this.api().columns('.select-filter').every(function () {.

    It seems to work good for me. No duplicate values, the select values look right and it performs the search.

    Not sure I'm clear on your problem description regarding how the values appear in your system. However there must be something else in your environment causing the issues. Maybe you can update the test case with more of your code to try replicating the issue.

    Kevin

This discussion has been closed.