Get the id of the respective Data Table
Get the id of the respective Data Table
I implemented my own state saving solution with state saving on the server via ajax. I save user_id, data table id and other attributes.
In "stateSaveCallback" and "stateLoadCallback" there is a "settings" parameter that allows me to get the data tables id (e.g. "#myDataTable").
stateSaveCallback: function(settings,data) {
var tableId = settings.nTable.id; //id of the data table
$.ajax({
type: "POST",
url: 'actions.php?action=saveState',
data: {
userId: currentUserId,
dataTable: tableId,
webPage: webPage,
width: percent,
values: JSON.stringify(data)
}
});
},
I also have a button to delete the saved state. I want the button to be reusable and hence need to get the id of the respective data table the same way as above. But I couldn't find a way to do this - which forces me to have an individual button for each data table.
Any idea?
{ name: "deleteState",
text: function () { return lang === 'de' ? 'Layout Reset' : 'Reset Layout' },
action: function ( e, dt, node, config ) {
$.ajax({
type: "POST",
url: 'actions.php?action=deleteState',
data: {
userId: currentUserId,
dataTable: "tblSubReg",
webPage: webPage
},
success: function () {
window.location.reload(true);
}
});
}
},
This question has an accepted answers - jump to answer
Answers
I got this work around now using the "node" parameter above:
Pretty ugly though. Any idea?
will do it there - using the
table().node()
method of thedt
(API instance) passed in.Allan