Prevent DataTables custom filter from affecting all tables on a page

后端 未结 4 1966
情深已故
情深已故 2020-12-21 23:23

When we add a custom filter to DataTables:

$.fn.dataTable.ext.search.push(function(settings, data, dataIndex) {
  ...         


        
4条回答
  •  有刺的猬
    2020-12-21 23:56

    Your simply doing a wrong approach here. $.fn.dataTable.ext.search.push has another purpose which you should never use when you multiple datatables in the page that you want to differently filter. The easiest way to build a custom search for a specific table is to build an array of unique ids for your data and later search it in your column id. Example:

提交回复
热议问题