Can filter (like 'where' clause) same JS Data for every table on same page?
Can filter (like 'where' clause) same JS Data for every table on same page?
Hi,
I'd like to share the same data source (JSON Javascript variable / NOT Ajax call) between multiple tables on the same page, each one filtered like this:
include only data from data source where column 'id' == table html attribute 'id'
Without implementing AJAX calls, is it possible to filter out JS source data in realtime from within datatable function (being able to access external data attribute)?
This is my actual code:
var $tabella = $('table.tabellaDanno').DataTable({
"data": dannoRelazioneJs,
"info": false,
"paging": false,
"searching": false,
"columns": [
{
"data": "descrizione",
"render": function(data) {
return "<div contentEditable=\"true\">" + data + "</div>";
}
},
{"data": "um"},
{"data": "quantita"},
{"data": "costoUnitario"},
{"data": "totaleNuovo"},
{"data": "statoUso"},
{"data": "totaleUso"},
{
"data": null,
"render": function(data) {
return "<a class=\"btn btn-danger\" name=\"eliminaRigaDanno\" title=\"Elimina Danno\" id=\""+data.id+"\"><span class=\"glyphicon glyphicon-minus-sign\"></span></a>"
}
}
]
})
Thank you for reading,
Alex
This question has an accepted answers - jump to answer
Answers
If you have multiple tables on the page, call them vars dT1, dT2, dT3, you can write some code that triggers the .filter() option for each of them.
docs are here
http://datatables.net/reference/api/filter()