The Process
I am going to use Appsmith to edit the item price using rest API
The Item List Table
Code
{{menitems.data.content}}
Explanation
From the Image, I have been Displaying my Item with the Edit Button in a table that I got from Rest API While Clicking I have been showing Item's details and the price to be changed
While Clicking the Edit Price Button
I have been Passing the Price from Table to the javascript object which I have been using storevalue to store the price which I will get the price and show in the popup
Code for Passing Table data to the Javascript Object
{{priceCalculation.openModal(currentRow.pricetype,currentRow.price)}}
Description
I have been passing the price from the table to the popup using the above code
Javascript Object code Open a Modal and storeValue
openModal:(price) => {storeValue("price",price);}
Description
Then in the Javascript object, I have been using storeValue to save in a local storage
The Modal Popup
Explanation
As you can see I have been getting the price from storeValue and adding in the input box's Default Value
In the Popup Price Input
{{appsmith.store.pricebefore}}
Description
From the above code I have been adding the price from the store value
Problem
When I change the text it rolls back the value from the storeValue
For Example
- price in storeValue = 300
- if I tried to change the price input to = 200
- then the input price rolls back to = 300
Solution Tried
in the price Input onTextChanged
{{(function({storeValue("pricebefore",price_before_discount.text);priceCalculation.price_before_change(price_before_discount.text);})()}}
Description
In the above code I have to change the text in storeValue too but it's way too slow if I edit too fast like double clear and add text way fast then it's taking too much time to reflect by the time it reflects it's rolling back the value in storeValue
For Example:
- The Text in Input = 12345
- if I press double bacspace then it's too slow it only clears one
- in the price input onSubmit
- If I use this it's working fine on Desktop but on mobile I can't submit the Input there is no Tick button on keyboard
Conclusion
I just need an alternative using the process of getting the price from the table and putting in the input and allowing the user to edit that input without interference