Example localStorage get the JSON array
Example localStorage get the JSON array
webworker
Posts: 3Questions: 1Answers: 0
Hello everybody,
the example https://editor.datatables.net/examples/advanced/localstorage.html suits my project.
How can I retrieve the complete JSON array and then delete the local store?
<button onclick="getResults()">get results as JSON array</button>
//that doesn't work
function getResults(){
//Get all records as JSON array.
var str = JSON.stringify(editor.formData());
document.getElementById("myResults").innerHTML = str;
//Delete localDatastorage
$('#example').DataTable().state.clear();
window.location.reload();
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @webworker ,
If you look at that page you linked to, there's an example around line 52 where that data is being removed. However, if it is deleted, that data won't be available for when the page is next loaded.
Cheers,
Colin
Hi Colin,
this is a method within the AJAX call. I would like to delete by clicking on the button. The question is, what's the syntax to access the editors DataSet?
In line 1 the editor var is set globally. It would have to be done but how?
regards
Use
rows().data()
(and addtoArray()
to get a plain array rather than a DataTables API instance) to get the data from the table. This effectively uses DataTables as the data store (not Editor).Allan
Perfect, that's what I mean Allan.