Reputation: 4759
I've a jquery datatable in which the search feature I want to be focused on the first column only. I mean If I input something on the search box, it should search that text in a specific column alone. I tried with a belief it should make the searching only for the second column
var myTable = $("#tbl_main").dataTable({
"dom": "<'tableinfobar'i><'tablesearchbox'f><'tablebody't><'tablelength'l><'tablepaging'p>",
"ordering": false,
"searching": false,
"columnDefs": [{
"targets": 1,
"searchable": true
}],
});
But it hides the search box completely
Upvotes: 0
Views: 953
Reputation: 4759
I found an answer myself and posting it so if it helpful to someone having similar issue
var myTable = $("#tbl_main").dataTable({
"dom": "<'tableinfobar'i><'tablesearchbox'f><'tablebody't><'tablelength'l><'tablepaging'p>",
"ordering": false,
"columnDefs": [{
"targets": [0, 2, 3, 4],
"searchable": false
}],
"lengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
"language": {
"search": "Search Person _INPUT_"
}
});
THis will search the input text in second column only
Upvotes: 0