jquery - Refresh datatable manually with already fetched data -
i have datatable initialized "empty" these options:
let options = { data: [], columns: [], datasrc: "" } let datatable = $(component).datatable(options); now datatable should updated ajax result not preformed datatable.
$.ajax({ url: "service/url/path", type: "get", success: function (data) { //todo: refresh datatable } }); all tutorials these 2 types:
- giving datatable ajax request's url datatable can update itself
- giving datatable js object upon initialization
what want this:
datatable.options.columns = { .. column settings .. }; datatable.data = newdata; datatable.refresh(); how can modify settings/options of datatable?
how can manually refresh data without recreating whole datatable?
if column configuration has changed, proper way re-initialize data table using destroy option.
from manual:
... if there existing datatable matches selector, destroyed , replaced new table. can useful if want change property of table cannot altered through api.
for example:
let options = { data: newdata, columns: [{ /* ... column settings ... */ }], destroy: true } let datatable = $(component).datatable(options);
Comments
Post a Comment