Search and HTML Data
Search and HTML Data
anthonyfrancq
Posts: 5Questions: 2Answers: 0
Link: https://www.affwise.io/dashboard/reports/clicks
Issue: When trying to search for any data that contains HTML after it will return no results.
Example: Go to the link above and search for Conversion or Click using the top right search input.
Code:
<script id="tablescript" type="text/javascript">
$(document).ready(function () {
$('#reports tfoot th').each( function () {
var title = $('#reports thead th').eq( $(this).index() ).text();
$(this).html('<input type="text" class="form-control" placeholder="Search by '+title+'" />');
});
$('#reports').DataTable({
"lengthChange": false,
dom: 'Bfrtip',
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"columnDefs":
[
{
"type": "html",
"targets": [0,1,2,3,4,5,6],
"searchable": true
}
],
initComplete: function () {
// Apply the search
this.api().columns().every( function () {
var that = this;
$('input', this.footer()).on('keyup change clear', function () {
if (that.search() !== this.value) {
that
.search(this.value)
.draw();
}
} );
} );
}
});
});
</script>
Answers
Your page isn't loading, I'm getting ERR_TOO_MANY_REDIRECTS. As a guide though, you can use
columns.render
, modifying thefilter
response, to determine how that cell should be matched.Colin