I am using the djando-datatables-view
tool to generate JSON data for the datatables jQuery plugin
. The data is being displayed correctly and sorting is working as expected. I have added an additional <input>
field to search data only in the second column of my table. However, when I input text into the 'search-input-text' field, I can see the processing modal but the table rows are not being filtered at all.
I have been unable to find any information on how to create custom filters using ajax.data
. As a newbie, I have spent the last three days trying to find a solution. Please help me:) Here is my code:
$(document).ready(function() {
var dataTable = $('#datatabletest').DataTable({
"processing": true,
"serverSide": true,
"ajax":{
"url" :"http://...tojson",
"type" : "get",
error: function(){
$(".datatabletest-error").html("");
$("#datatabletest").append('<tbody class="datatabletest-error"><tr><th colspan="3">ERROR</th></tr></tbody>');
$("#datatabletest_processing").css("display","none");
}
}
});
$("#datatabletest_filter").css("display","none");
$('.search-input-text').on( 'keyup', function () {
var i = $(this).attr('data-column');
var v = $(this).val();
dataTable.columns(i).search(v).draw();
});
});