Add a new row on a filtered table.

Add a new row on a filtered table.

thatsanothatsano Posts: 1Questions: 1Answers: 0

I have a dataTable that, once it finishes loading on the page, it calls

$.fn.dataTable.ext.search.push(
    function(settings, data, dataIndex) {
        return $(table.row(dataIndex).node()).attr('data-status') == 'P';
    }
);

to filter out to only rows with the data-status = P. Whenever I add a new row:

var toAdd = [
   'cell 1',
   'cell 2',
   'cell 3',
   'cell 4',
   'cell 5',
   'cell 6',
   'cell 7',
   'cell 8'
];
toAdd.id = someId;
toAdd.status = 'P';
table.row.add(toAdd)
table.draw();

Nothing pops up. The only way I can actually see the data pop up and filtered by pending is if I do the following:

$.fn.dataTable.ext.search.pop();
table.draw();

and then manually use a dropdown to filter out pending results again.

Is there anyway to add, and render with the filters still in place?

This discussion has been closed.