You need to sign in to do that
Don't have an account?
Nagarjuna Reddy.P
populate picklist field value on select LWC
Hi,
I've to populate the saved picklist value on UI for HTML Select, and I'm completely struck with this.
Here is my select
<tbody>
<template for:each={updatedItemList} for:item="updatedItem" for:index="index">
<td>
<select name="Time Frames" class="select slds-select" data-label='timeFrames' data-index={index} onchange={itemUpdate}>
<option value="" >Select an Option</option>
<template for:each={itemList} for:item="item">
<option key={item.label} value={item.value} selected={item.selected}>{item.label}</option>
</template>
</select>
</td>
</template>
</tbody>
In Js Controller getting the slected value using event.target.value and passing to apex method where the upsert operation occurs and the picklist value updated successfully but the updated value is not populating at UI.
Here the updatedItemList has the latest updated value and when I tried by replacing value attribut for <option> as value={updatedItem.value} , I'm getting the current field value from database and same value is passing to apex from event.target.value , but here need to get the current value selected.
Can you people please suggest me how to resolve this.
Thank you.
I've to populate the saved picklist value on UI for HTML Select, and I'm completely struck with this.
Here is my select
<tbody>
<template for:each={updatedItemList} for:item="updatedItem" for:index="index">
<td>
<select name="Time Frames" class="select slds-select" data-label='timeFrames' data-index={index} onchange={itemUpdate}>
<option value="" >Select an Option</option>
<template for:each={itemList} for:item="item">
<option key={item.label} value={item.value} selected={item.selected}>{item.label}</option>
</template>
</select>
</td>
</template>
</tbody>
In Js Controller getting the slected value using event.target.value and passing to apex method where the upsert operation occurs and the picklist value updated successfully but the updated value is not populating at UI.
Here the updatedItemList has the latest updated value and when I tried by replacing value attribut for <option> as value={updatedItem.value} , I'm getting the current field value from database and same value is passing to apex from event.target.value , but here need to get the current value selected.
Can you people please suggest me how to resolve this.
Thank you.
Kindly check these links which may helps :-
1. https://www.salesforcecodecrack.com/2019/03/how-to-fetch-picklist-values-in.html
2. https://salesforce.stackexchange.com/questions/285174/populate-lwc-select-with-values-from-values-in-a-record-field
3. https://salesforce.stackexchange.com/questions/260959/lwc-get-pick-list-field-values
Kindly mark it as the best answer if it works for you.
Thanks & Regards,
Priya Ranjan