Displaying data from Localstorage

Displaying data from Localstorage

fahadkhanfahadkhan Posts: 7Questions: 3Answers: 0

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

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Are you using Editor to edit those fields?

    If not, you'll need to do something with stateSave. You can use stateSaveParams and stateLoadParams to add additional data to the local storage - which in your case would be the modified quantities.

    Colin

  • fahadkhanfahadkhan Posts: 7Questions: 3Answers: 0

    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


    { "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">' } }

    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.

This discussion has been closed.