Ac. Selvan
Ac. Selvan

Reputation: 71

Appsmith to change the default value of the Input Box

The Process

I am going to use Appsmith to edit the item price using rest API

The Item List Table

enter image description here

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

enter image description here

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

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:

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

Upvotes: 3

Views: 1000

Answers (1)

Appscript.me
Appscript.me

Reputation: 45

let's use the setValue method to set default value for the input. It will not restore the value when the user inputs.

Upvotes: 0

Related Questions