Set ajax.dataSrc after table initialization

Set ajax.dataSrc after table initialization

Neve12ende12Neve12ende12 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();

Answers

  • allanallan Posts: 63,712Questions: 1Answers: 10,502 Site admin

    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() and rows.add() to clear existing rows and add the new data (which is basically what ajax.reload() does itself).

    Allan

This discussion has been closed.