0

Displaying the Set<String> value in lightning-radio-group

"filterlabel": "Age",
"filterValue": ["9-13", "5-8"]

From My Controller, I'm getting filterlabel and filterValue , When i tried to display the filterValue in lightning-radio-group i'm getting empty radio group button as below. (the controller will return an array of object, Each object has a Own filter - Dynamic filter)

enter image description here

<lightning-radio-group 
    name="filter" 
    label={sub.filterlabel}
    options={sub.filterValue} 
    type="button">
</lightning-radio-group>

1 Answer 1

0

Options need to be in the specific format. { label: 'Sales', value: 'option1' }.

so

 "filterValue": [
    "9-13",
    "5-8"
]

should be.

 "filterValue": [
    { "label": "9-13", "value": "9-13" },
    { "label": "5-8", "value": "5-8" }
]

You can create a wrapper class in apex for that.

public class OptionWrapper{
    @auraEnabled
    public string label{get;set;}
    @auraEnabled
    public string value{get;set;}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.