How can I filter the table using an external button/function?
How can I filter the table using an external button/function?
Hi. This seems really simple but I'm having troubles.
Right now I have a few buttons declared within the table, like this:
buttons: [
{
text: 'Todos',
action: function (e, dt, node, config) {
dt.column(7).search("").draw();
}
},
{
text: 'Completados',
action: function (e, dt, node, config) {
dt.column(7).search("Completado").draw();
}
},
{
text: 'Pendientes',
action: function (e, dt, node, config) {
dt.column(7).search("Pendiente").draw();
}
}
],
I use them to filter the table based on those given conditions.
Now I need to declare and call a function OUTSIDE the datatable declaration, that also filters the table (based on a condition that I'll decide later).
How can I do it?
Thanks in advance.
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Hi Colin, thanks for the answer (and sorry for the delay)
I wouldn't know what to write in the test case (never wrote one), because my doubt is exactly something I have no idea how to write.
I just want to write a Javascript function that filters the table depending on the value of a certain column. The parameter of said function would be the value.
I want this:
but on a Javascript function OUTSIDE my datatable declaration, which is:
$('#tableName').dataTable( {
});
If you still need a test case it's fine. Thanks in advance
Does this example help?
http://live.datatables.net/bexukuka/1/edit
If you still need help then please update the test case showing what it is you are trying to do. Or provide a more detailed description of the solution you are trying to acheive.
Kevin
That looks exactly like what I need. Thank you so much!