problem refresh data DataTable
problem refresh data DataTable
Hi, I am new for this forum,my english is bad, I have a problem I am using this method:
https://datatables.net/examples/data_sources/js_array.html
So, I need that when I click on the button, refresh with new dataSet, I tried it with ajax.reload but it does not work "Uncaught TypeError: Cannot set property 'data' of null".
// It is executed at the time of initial loading
var dataSet = $.loadJSON('getHitoAdminSeguimientoForTabla/0/'+null+'/'+null);
var table = $('#tablePanelControlHitosAdmin').DataTable( {
"paging": true,
"ordering": false,
"info": false,
"searching" : true,
"scrollX": true,
data: dataSet,
columns: [
{ title: "id"},
{ title: "descripción"},
{ title: "estado"},
{ title: "fecha pgm"},
{ title: "fecha control"},
{ title: "días atraso"},
{ title: "multa fija(UF)"},
{ title: "multa diaria(UF)"},
{ title: "multa fija(UTM)"},
{ title: "multa diaria(UTM)"},
{ title: "multa fija pesos"},
{ title: "multa diaria pesos"},
{ title: "multa total"}
]
} );
//here is where we get the new data
$.refreshTable = function(){
dataSet = $.loadJSON('getHitoAdminSeguimientoForTabla/4/4/4');
table.ajax.reload();
}
refreshTable function is the one that triggers the error when called.
Please, help me, and sorry for my bad english. thank you very much.
This question has an accepted answers - jump to answer
Answers
To use
ajax.reload()
you need to define theajax
option in Datatables. Since you are fetching the data you will need to useclear()
followed byrows.add()
to clear then add the fetcheddataSet
.Kevin
thanks men, this work for me.