filtering - jQuery dataTables - Clear search on a column -


looking @ example, http://www.datatables.net/examples/api/multi_filter_select.html, uses columns.search() datatable api, how 'clear' search , show results again when user selects 'all' or empty first option?

you clear search using empty string search term, without regular expression match. individual column filtering demo somehow little bit misleading, since first (unnamed) option not "all" or "any", 1 belive, in fact should named "empty" or "null". if select first option, regular expression search empty string performed. guess demo made in haste.

modified demo selecting first option "clear" search, selecting :

$("#example tfoot th").each( function ( ) {   var select = $('<select><option value="">all</option></select>')     .appendto( $(this).empty() )     .on( 'change', function () {        var term =  $(this).val()!='' ? '^'+$(this).val()+'$' : '';        table.column( )           .search(term, true, false )           .draw();        } );    table.column( ).data().unique().sort().each( function ( d, j ) {     select.append( '<option value="'+d+'">'+d+'</option>' )   }); }); 

modified individual column filtering demo -> http://jsfiddle.net/cmmfj/


Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -