3

I am pretty surprised at how custom filtering works in datatables. It seems like i need to define a global filter function like this:

$.fn.dataTableExt.afnFiltering.push(function (oSettings, aData, iDataIndex) { .. });

and then ALL datatables on my page will use that function to filter. This is not acceptable.

What i need is a way to programmatically filter a datatable using a custom filter function. I would expect this function to take a row and return true/false based on some criteria to show/hide that row from the result.

does a way of doing this exist?

1 Answer 1

2

does this link help:

http://datatables.net/forums/discussion/8435/remove-custom-filtering/p1

/* Custom filtering function which will filter data in column four between two values */
$.fn.dataTableExt.afnFiltering.push(
        function (oSettings, aData, iDataIndex) {
            if ( oSettings.nTable.id === "my_filtering_table" ) {
                var selectCode = document.getElementById('statusSelect').value;
                return filterRow(selectCode, aData);
            }
            else {
                return true;
            }
        }
);
Sign up to request clarification or add additional context in comments.

1 Comment

actually my solution ended up being very similar. I am both happy and sad that the author endorses this hack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.