How to use fnFilterOnReturn
How to use fnFilterOnReturn
Description of problem: When I was trying to use the data tables default serach available on the top-right corner for the plugin fnFilterOnReturn I'm unable to get any results
$(document).ready(function () {
$("#ddlJobId").select2();
$("#ProjectId").select2();
$("#JobStatusId").select2();
$("#EmployeeId").select2();
$('#refreshbtn').click(function () {
location.reload();
$('#TableJobs').dataTable().fnFilterOnReturn();
});$('#TableJobs').dataTable().fnFilterOnReturn();
});
var jobsTable = $('#TableJobs').DataTable({
"lengthMenu": [20, 40, 60, 100],
"pageLength": 20,
"processing":true,
"serverSide": true,
"filter": true,
"language": {
"infoFiltered": "",
"processing": "<i class='fa fa-cog fa-spin fa-4x fa-fw'></i> <br/> Loading...." //"<i class='fa fa-refresh fa-spin'></i>"
},
"ajax": {
"url":'@Url.Action("DashboardJobs", "Home")',
"type": "POST",
"datatype": "json"
},
"columnDefs": [{
"targets": [0],
"visible": false,
"searchable": false
}],
"columns": [
//<td> "EditJob", "EditJob", new { id = x.JobNo }, null) </td>
{ "data": "id", "name": "id", "autoWidth": true },
{
"data": "jobNo", "name": "jobNo", "autoWidth": true, "type": "string",
render: function (data,type,job) {
return "<a href='../EditJob/EditJob/" + job.jobNo + "'>" + job.jobNo + "</a>";
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
Replies
Do you get any errors, either alerts or console?
Are you loading the plugin code?
Just to make sure it works with the current version of Datatables I built this server side processing test case and the plugin works:
http://live.datatables.net/fukunebo/1/edit
Note I initialized the plugin after initializing Datatables to avoid the Cannot reinitialise DataTable error. If this doesn't help then please post a link to your page or a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin