Filter DataTable with text box
Filter DataTable with text box
I'm trying to filter DataTable, with a text box that s not built into datatable functionality. I followed all the instructions but the search[value] is always empty string when I do the keyup function. Following is the code I am using. Thanks in advance.
var table = $("#my-table").DataTable({
"searching": true,
"destroy": true,
"order": [[2, "asc"]],
"processing": true,
"bfilter": false,
"language": {
"processing": "Loading Data... Please Wait"
},
"serverSide": true,
stateSave: false,
"lengthMenu": [[10, 25, 50, 100], [10, 25, 50, 100]],
"pagingType": "simple_numbers",
"info": true,
"ajax": {
"url": urlAction,
"type": "GET",
"data": {
"nameCD": nameCode
}
},
"select": {
"style": "multi"
},
"sDom": '<"dt-header font-bold">lrt<"dt-footer"ip>'
});
$('#searchMergeName').on('keyup', function () {
table.columns(2).search(this.value).draw();
});
<input class="form-control" id="searchMergeName" type="search" placeholder="Search Names">
Answers
Please see my responses here
Thanks for the reply but that's not quite what I'm looking for. If you see the image attached, I just have a text box that when I type text in it. Filters the datatable by name column. And the documentation from data table just shows you do the following and it should filter:
$('#searchMergeName').on('keyup', function () {
table.columns(2).search(this.value).draw();
});
see here:
https://datatables.net/reference/api/search()
ahh ok I misread your requirement. Give YADCF plugin a look
Thanks, this looks like it will work for what I want to do.