Trouble Filtering Displayed Data
Trouble Filtering Displayed Data
jtodd
Posts: 4Questions: 2Answers: 0
Hi There,
I am having trouble filtering the data displayed by DataTables using both the filter function on initComplete and the search/searchCols functions. I am including both of my attempts at filtering but only expect to use one in the final code.
fulcrumDomainTable = $('#fulcrum-domain-table').DataTable({
"processing": true,
"paginate": false,
"scrollY": "200px",
"scrollCollapse": true,
"dom": '<"top">rt<"bottom">',
"filter": false,
"ajax": {
"url": fulcrumDomainUrl,
"dataSrc": "fulcrumDomainStatuses"
},
"initComplete": function(){
this.DataTable().columns([1]).data().filter(function(v,i) {
return v === "D01";
});
$("#fulcrum-domain-table-footer").text("Request UUID " + uuid);
$("#fv-row-6").show();
fulcrumDomainTable.columns.adjust().draw();
},
"order": [[1,'asc']],
"columnDefs": [
{"targets": "dateCol",
"render": function(value) {
return formatDate(value);
}
}
],
"search": {"search": "D01"},
"columns": [
{"className": "details-control",
"orderable": false,
"data": null,
"defaultContent": ''},
{"data": "domain"},
{"data": "resultTypeCode"},
{"data": "transactionDate"}
]
});
Thanks!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This should work.
filter()
won't work. This is in the doc for filter():You could try something like this:
If neither works for you then we probably need to see a non-working example with your data. I can build generic test cases to show either of these working.
Kevin
Thanks!
I tried:
this.DataTable().columns([1]).search("D01" ).draw();
But that also didn't work.
Here is some data:
Domain Result Type Code Tran Date
D01 NO_DATA 2017-08-17T14:54:24Z
D02 NO_DATA 2017-08-17T14:54:24Z
D03 NO_DATA 2017-08-17T14:54:24Z
Column 0 is detail-controls so Domain is in column 2.
I agree search should work the way I have it, I also tried searchCols with no luck.
I got it!
I took out:
"filter": false,
then
"search": {"search": "D01"},
works perfectly.