search filter after change in table
search filter after change in table
Hi, Im working in a project where the user can change the status of a group from "available" to "disavailable" in a table, the problem I have is that after I change the status, I want datatables to filter between available and disavailable, but because I have changed the status datatables doesn't recognise the change and if I changed available to disavailable the filter would recognise disavailable as available.
This is the code im using to change the status:
[code]
if(text === "available"){
var div_hab = "<i id='status'> Disavailable</i>";
param.attr('class', 'fa fa-lock disavailable');
param.html(div_hab);
}
if(text === "disavailable"){
var div_hab = "<i id='status'> Available</i>";
param.attr('class', 'fa fa-unlock available');
param.html(div_hab);
}
[/code]
I hope someone could help me, thanks in advance
Answers
Hi, I'm new to datatables, I had a simular problem, the code below solved my problem.
I call it before applying the filter, it updates the datatable based on the current html.
if you are using ajax data try "table.ajax.reload();" instead.
[code]
table
.rows()
.invalidate()
.draw();
[/code]
Hope this helps,
Cheers Patrick