Using Invalidate() along with type based filter
Using Invalidate() along with type based filter
If I have a custom type based search filter, like a HTML input :
$.fn.dataTableExt.ofnSearch['html-input'] = function(input) {
return $(input).val();
};
and the content is changed by the user, or by code, then search / filter will still search / filter on the old value. I have tried using validate(), but this does note seem to work - either on individual cells or table rows.
$("#example td input").on('change', function() {
var td = $(this).parent();
table.cell(td).invalidate().draw();
//doesnt' work either
table.rows().invalidate(); //auto, data or dom does not make any difference
});
see demo -> http://jsfiddle.net/smudwkwo/
Have I missed the purpose of invalidate, or is there any other way to "refresh" the internal prepared list of filtering values? Is there a way to force the custom filter function, eg $.fn.dataTableExt.ofnSearch['html-input'] to be called?
Answers
I figured it out. Invalidate() works well, but changing the value of a input box does not change the underlying value attribute. To come over this problem, I found out to set the value manually after change, and then call invalidate.
see demo -> http://jsfiddle.net/3xm5nz95/