how to use filter
how to use filter
anshik
Posts: 2Questions: 1Answers: 0
https://datatables.net/reference/api/filter()
I put data-filter to td attributes.
<td class="text-right" data-filter="{{ obj.id }}">{{ obj.last_status_change|user_timezone:request|date:"SHORT_DATE_FORMAT" }}</td>
I can see list of data-filter in console
dataTable
.column( 3 )
.nodes().filter( function ( value, index ) {
console.log($(value).data('filter'));
})
I can apply function to filtered data:
dataTable
.column( 3 )
.nodes().search( function ( value, index ) {
return $(value).data('filter')>33876;
})
filter() returns DataTables.Api (type)
How i can show filtered data in current table, and return source table back?
like in search:
$('#searchinput').on( 'keyup change', function () {
dataTable.search($(this).val()).draw();
} );
$('#searchclear').on("click", function() {
$('#searchinput').val("");
dataTable.search('').draw();
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The
filter()
method only filters the API object's data - not the table itself. From its documentation:Furthermore, the
search()
documentation notes that it does not accept a function.If you want to apply a function for a search you need to use a plug-in function.
Allan
Thank you, Allan.
After few hours it works