Exact word search using Tablepress/datatabple
-
Im using Tablepress wordpress plugin (I’ve already written code for “Press enter to search and hidden table and search speficic columns” ). Now I want EXACT WORD SEARCH i.e user will see results only when he types exact word/number.
Note: I’ve found some solutions here but don’t understand where to place exactly
1. https://stackoverflow.com/questions/19114586/how-to-get-exact-match-using-fnfilter
2. https://www.datatables.net/forums/discussion/4096/filtering-an-exact-match/p1HERE IS THE LINK: https://appache.no/hydor
And here is the code Im using
<script type="text/javascript"> $(document).ready( function () { var table = $('#tablepress-1').dataTable( { "aoColumnDefs": [ { "bSearchable": false, "aTargets": [ 0,2,4,5,6,7,8]} ],"bLengthChange":false,"iDisplayLength":1 } ); window.alert = function() {}; $.fn.dataTableExt.afnFiltering.push( function( oSettings, aData, iDataIndex ) { return oSettings.oPreviousSearch.sSearch === '' ? false : true; } ); var DT_tablepress_1 = $('#tablepress-1').dataTable({"aaSorting":[],"bSortClasses":false,"asStripeClasses":[],"bSort":false,"bLengthChange":false,"iDisplayLength":1,"bInfo":false}); $('#tablepress-1_filter input').unbind().bind('keyup', function(e) { if( 13 == e.keyCode ) DT_tablepress_1.fnFilter( this.value ); }); $( '.dataTables_filter' ).find( 'input' ).on( 'keyup', function(e) { if( 13 == e.keyCode ) { $( '.dataTables_wrapper' ).find( '.tablepress' ).toggle( '' != $(this).val() ); } } ); $( '.dataTables_wrapper' ).find( '.tablepress' ).hide(); }); </script>
- The topic ‘Exact word search using Tablepress/datatabple’ is closed to new replies.