Search being called multiple times

Search being called multiple times

miztakenmiztaken Posts: 1Questions: 1Answers: 0
edited September 2015 in DataTables 1.10

I am doing server side filtering in my application. I have used the approach outlined on https://datatables.net/examples/api/multi_filter.html to render input text element on header of each column. I am also following the approach where the column(idx).search().draw() gets called only when ENTER Is pressed after typing search text.
Like this:-

var tbl = $("#tableid").DataTable();
        tbl.columns().eq(0).each(function (colIdx) {
            $('input', tbl.column(colIdx).footer()).on('keydown', function (evt) {
                if (evt.keyCode === 13) {
                    tbl.column(colIdx).search(this.value).draw(); ///called_line
                }
                
            });
            $('input',tbl.column(colIdx).footer()).on('click', function (e) {
                e.stopPropagation();
            });
        });

Now whenever i type some text and press ENTER in any of the input fields on header of any column. The tbl.column(colIdx).search(this.value).draw() is called for all existing column in the table. i.e. for each ENTER, the ajax method gets called X number of times, where X is number of columns in the table.

Thank You

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Can you link to the page showing the issue please. I don't immediately see why the above code would work and it would need to be debugged.

    Allan

This discussion has been closed.