Save form data offline

Save form data offline

Hildeb67Hildeb67 Posts: 87Questions: 24Answers: 1

Hello, I have a mobile application used on a tablet.
The internet connection frequently drops. Is there a way to temporarily save the form data and upload it to the server when an internet connection is established? Is this possible with DataTables Form? Ideally, I'd like the data to be saved every time the user leaves the form field. Thanks and regards, Chris

Answers

  • allanallan Posts: 65,588Questions: 1Answers: 10,904 Site admin

    Hi Chris,

    Have a look at this blog post which describes how you can save the changes locally and then have the user submit them in a batch with a button press.

    Perhaps in your case you might want to go a step further, and instead of having a button to save changes, detect when the connection is up / down and when it comes back, if there are any changes, automatically submit them?

    Allan

  • Hildeb67Hildeb67 Posts: 87Questions: 24Answers: 1

    Hi Allan, thanks for the tip. I've now solved it with localStorage.setItem("..") and val(localStorage.getItem..") for the form fields.

    But now the question is: How can I save an entire table like this? Can this also be done with localStorage? Do you perhaps have an example?

    Thanks and regards, Chris

  • kthorngrenkthorngren Posts: 22,405Questions: 26Answers: 5,147

    You can use rows().data() to get the table data. Chain toArray() to change the result to a standard Javascript array. Use JSON.stringify() to convert to a JSON string for local storage. Use JSON.parse() to reverse this when retrieving from local storage.

    Kevin

Sign In or Register to comment.