1

Currently search text is searching on all columns. I just want to search on first column and also want to highlight the searched text. I red the documentation of datatable but it getting over from my mind. Is there any simple way to get this done. fiddle

$(document).ready(function(){    
   var table= $('#example').DataTable({
        paging:false,     
        ordering:false
    });

    $('#search-inp').keyup(function(){
      table.search($(this).val()).draw() ;
})

});
Jitender
  • 7,593
  • 30
  • 104
  • 210

1 Answers1

2

There is one option in dataTable UI it is search column property. if you want serach the first column only means you just put .column(1)

$('#search-inp').keyup(function(){
       table.columns(1)
       .search($(this).val()).draw() ;
})

for hide the default search add the line

 $(".dataTables_filter").hide();

Fiddle

Note : Doc from https://datatables.net/reference/api/column().search()

Sudharsan S
  • 15,336
  • 3
  • 31
  • 49
  • Thanks, Your fiddle is working fine, just need to know Can we hide default search input? – Jitender Apr 21 '15 at 11:11
  • `$(".dataTables_filter").hide();` – Sudharsan S Apr 21 '15 at 11:14
  • Thanks once again, I just notice that the it is filtering all the result which match with the search text. How to enable exact match. like if I have "avenger" and "myavenger", If I type "aven" then only first one will display – Jitender Apr 21 '15 at 11:20
  • I checked this http://stackoverflow.com/questions/8609577/jquery-datatables-filter-column-by-exact-match but it seems not working – Jitender Apr 21 '15 at 11:20
  • You ask lot of questions better than you will raise a question independently. Thanks – Sudharsan S Apr 21 '15 at 11:26