最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - datatables custom filtering - Stack Overflow

matteradmin4PV0评论

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?

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?

Share Improve this question asked Aug 30, 2012 at 14:56 mkoryakmkoryak 58k64 gold badges203 silver badges262 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

does this link help:

http://datatables/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;
            }
        }
);
Post a comment

comment list (0)

  1. No comments so far