As per this example, is it possible to pass the data from stateRestore data.stateRestore into a function of the custom button?
Test case here
You can call the API within the custom button's code - stateRestore.states() give you data about all the states,
Thank you for looking into this! I tried this here, but it does not seem to get the needed array.
If this works, how would I also get the identifier for the specific state of the button clicked so I could get something like this: table.stateRestore.states(identifier)
I think info here is missing for "Returns a DataTables API containing the desired states so that chaining can occur": https://datatables.net/reference/type/DataTablesApi
You can traverse the DOM to find the State Save name. Use the browser's inspect tool to see the DOM structure. Maybe something like this:
@Kevin Getting the state names works, thanks so much! Still not sure how to get the correct array table.stateRestore.states(identifier) as the test case seems to hang up.
It can be slow to open the console output of the APIs at times. Here is a screenshot:
Is this what you are looking for?
If the test case locks up for you then try it on your local system.
@Kevin Apologies! It does work, thank you so much. How do you get to the saved state values specifcally? console.log(table.stateRestore.states( [name] ).stateRestore); does not work and neither console.log(table.stateRestore.states( [name] )[38);
console.log(table.stateRestore.states( [name] ).stateRestore);
console.log(table.stateRestore.states( [name] )[38)
The results are returned into an array of one or more StateRestore objects. You can access the first and only result like this table.stateRestore.states( [name] ), for example:
table.stateRestore.states( [name] )
It looks like you're new here. If you want to get involved, click one of these buttons!
DataTables designed and created by SpryMedia Ltd.
SpryMedia Ltd is registered in Scotland, company no. SC456502.