JQuery DataTables plugin - adding a custom parameter selection filter

Does anyone know how to add a custom parameter selection filter to jQuery DataTable?

In principle, for example, an example page , but instead of the minimum text fields ... change them to select options.

+4
source share
2 answers

Easier than I thought it would be:

Javascript

$(document).ready(function() { /* Initialise datatables */ var oTable = $('#example').dataTable(); /* Add event listener to the dropdown input */ $('select#engines').change( function() { oTable.fnFilter( $(this).val() ); } ); } ); 

HTML

 <select id="engines"> <option value="">- Select -</option> <option value="1.8">1.8</option> <option value="1.9">1.9</option> </select> 
+13
source

You need to create a regex that will do this. Creating a minimum or maximism is quite simple. Trying to do both becomes difficult. Here is one that will return all 13+ numbers:

 oTable.fnFilter("([1-9][3-9]|[2-9][0-9]|[0-9]{3,})", 1, true); 

This says: 13-99 (excluding 20, 21, 22, 31, 32, etc.) 20-99 100 +

+2
source

Source: https://habr.com/ru/post/1310449/


All Articles