jquery - DataTables search on specific columns -


i have adapted following webpage needs , added bit of code has select2 dropdown menus instead of regular select menus (which lot better). have not been able figure out how adapt code can use on specific columns instead of on every column. guidance appreciated.

http://datatables.net/examples/api/multi_filter_select.html (code adapted)

initcomplete: function () {         this.api().columns().every( function () {             var column = this;             var select = $("<select class='searchs2'><option value=''></option></select>")                 .appendto( $(column.header()).append() )                 .on( 'change', function () {                     var val = $.fn.datatable.util.escaperegex(                         $(this).val()                     );                     column                         .search( val ? '^'+val+'$' : '', true, false )                         .draw();                 } );             column.data().unique().sort().each( function ( d, j )              { select.append( '<option value="'+d+'">'+d+'</option>' )});         });         $(".searchs2").select2();     } 

also - if there option hide 'generic' search box hide on top , provide these select2 boxes. thank you.

(edited update fix select2 initialize every dropdown box, last 1 not initializing)

you can use columns([array]). instead of

this.api().columns().every( function () { 

and want perform search on column 1,2,5 , 6 :

this.api().columns([1,2,5,6]).every( function () { 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -