Display a label of the current active state
Display a label of the current active state
CT General Assembly
Posts: 20Questions: 3Answers: 1
in DataTables 2
Regarding this example, https://datatables.net/extensions/staterestore/examples/customisation/activeLabel.html
Is there a way to get the "current" state rather than just all of the Active States to be able to display that?
This question has an accepted answers - jump to answer
Answers
You can use
state()
to get the current state object of the DataTable. Is that what you mean?Allan
Does that give the name of it?
We have the states implemented and are letting the users rename them and so on. They want to see the name of the current state that they have chosen.
I ended up figuring it out and am doing it this way:
DataTable.ext.buttons.stateRestore.action = function (e, dt, node, config) {
config._stateRestore.load(config._stateRestore.s.identifier);
$('.dataTables_info').html($('.dataTables_info').html().toString() + ' Current View: ' +config._stateRestore.s.identifier);
};
Oh I see what you mean - I thought you were looking for the state at any point, regardless of if it has been restored or not.
Yes, it isn't ideal and I think the StateRestore API could be improved for a few things like this.
Good to hear you found a solution for now.
Allan