You need to sign in to do that
Don't have an account?
Ragnar Lothbrok 7
How to set the value of lightning-combobox of list of object in LWC?
Hi,
I have a Lwc component there i am showing the list of fields with 3 rows, for that row we have values in it and that value is comming from this code :
And the Html code is :
And the UI is here :
I wanted to have the default value for each row. On pageLoad directly, I tried but unable to do that, please guide me how to achieve that.
Thanks
I have a Lwc component there i am showing the list of fields with 3 rows, for that row we have values in it and that value is comming from this code :
getPickListValues({ objApiName: 'OpportunityContactRole', fieldName: 'Role' }) .then(data => { //console.log('OUTPUT : Picklist data :',data); for (let index = 0; index < data.length; index++) { if(data[index].label=='L3' || data[index].label=='L4' || data[index].label=='L5'){ this.temp.push(data[index]); } } this.options = this.temp; console.log('OUTPUT : TempData',this.options); }) .catch(error => { console.log('OUTPUT Error: ',error); });
And the Html code is :
<template for:each={contactList} for:item="contact" for:index="index"> <tr key={contact.Id}> <td> <!--<lightning-formatted-text data-index={index} value= {contact.role}></lightning-formatted-text>--> <div class="slds-var-m-bottom_medium slds-var-p-right_medium"> <template if:true={options}> <lightning-combobox data-index={index} class="myCombobox" placeholder={label.Contact_Role_Placeholder} name="Role" value= {contact.role} options={options} onchange={onRoleChange} > </lightning-combobox> </template> <!--<p>Selected value is: {contact.role}</p>--> </div> </td> <td> <template>
And the UI is here :
I wanted to have the default value for each row. On pageLoad directly, I tried but unable to do that, please guide me how to achieve that.
Thanks