Displaying data from Localstorage
Displaying data from Localstorage
![fahadkhan](https://secure.gravatar.com/avatar/05e37fd54bf5b7a482eb3a0bab123afa/?default=https%3A%2F%2Fvanillicon.com%2F05e37fd54bf5b7a482eb3a0bab123afa_200.png&rating=g&size=120)
Hi,
I have a datatable showing the product catalouge , in every rows I have text field so user can enter the required qty. Once user add qty I add them in local storage. I am creating text field using the code below
{
"data": "orderQty",
render: function (data, type, row) {
return '<input class="quantity-input" value="" type="number" data-id=' + row.productCode + ' data-price="51.00" data-available="158">'
}
}
The problem I am havig now is, if user add few products in his cart then for some reason he leave the site , when the user come back again on the site and browse product catalogue I want to populate the text field (required qty) with the value from the local storage.
Please help.
Thanks
Answers
Are you using Editor to edit those fields?
If not, you'll need to do something with
stateSave
. You can usestateSaveParams
andstateLoadParams
to add additional data to the local storage - which in your case would be the modified quantities.Colin
Hi Colin,
Thanks for your reply and giving mew few pointers. I spent few hours but still couldnt make it work.
this is the data table I am loding from rest api
I am creating the Qty field using the code below
There will be loads of these fields , as it is a product ordering catalouge. So once user put Qty in this field I am storing the qty and product Id in local storage. If user logs out or leave the order un completed , when user returns I would like to load the saved Qty fields from local storage in to specific Qty fileds.
Please let me know if it is possible. I am not using Editors.
Thanks a lot.