Set ajax.dataSrc after table initialization
Set ajax.dataSrc after table initialization
Neve12ende12
Posts: 1Questions: 1Answers: 0
I am trying to load data on button click via ajax. The only problem is I keep getting an error because ajax.DataSrc !== ''. I know I can set if when I initialize the dataTable, but I don't want to because I don't want the ajax to fire until button click.
I am doing the following on button click:
table.ajax.dataSrc = '';
table.ajax.url(window.resolveUrl('~/reports/getEvents/' + startDate + '/' + endDate)).load();
I can't do it on page load because the user has not specified startDate & endDate. So again, is there a way to set the dataSrc before I do
table.ajax.url(window.resolveUrl('~/reports/getEvents/' + startDate + '/' + endDate)).load();
This discussion has been closed.
Answers
There is no option to set that parameter after initialisation I'm afraid. You would need to make the Ajax call yourself and then use
clear()
androws.add()
to clear existing rows and add the new data (which is basically whatajax.reload()
does itself).Allan