You need to sign in to do that
Don't have an account?
Lightening Web component combobox is not working
Hi,
I am trying to create a lightening web component combobox but it's not working. Please check the code
Javascript:
import { LightningElement, api, wire, track } from 'lwc';
import methodName from '@salesforce/apex/MoveAttachment.methodName';
export default class attachmentMove extends LightningElement {
@track record;
@track result;
@track error;
@wire(methodName)sobjectName;
wiredsobjectName({error, data}){
if(data){
if(data.length>0){
this.arrays.array.forEach(element => {
this.record.push ({label: record[i].Id, value: record[i].Name });
console.log('check=====>', this.result);
});
}
this.result = record;
this.error = undefined;
} else if (error){
this.error = error;
this.result = undefined;
}
}
get options() {
console.log('option--->', this.sobjectName.data);
return this.sobjectName.data;
}
get values(){
return this.result;
}
handleChange(event) {
this.value = event.detail.value;
}
}
/*
*/
HTML:
<template>
<lightning-card title="Combo Box_Type Values" icon-name="custom:custom67">
<template if:true={sobjectName.data}>
<lightning-combobox
name="List of Object"
label="List of Object"
value={result}
placeholder="Select Object"
options = {options}
onchange={handleChange} >
</lightning-combobox>
<p>Selected value is: {options}</p>
</template>
</lightning-card>
</template>
If use get option then it shows blank value in dropdown, if i use this.result. then it does not work. say this.result is undefined and also this.result. Please help me to fix it.
Thanks and regards
Nishant Shrivastava
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
When I attempted CharuDutt's solution, I got an error:
[this.data is not iterable]]
Not sure if I am the only person who this happened to, but there you go.