0

I'm utilizing a LWC radio group for my user option selection, where the Options Label is a Record Name and the Value is the matching Id. I was able to correctly retrieve the Value, or Id, from the radio selection using the onchange event as described below. I also need to retrieve the Record Name, i.e. Label, of the selected Radio option using js. I would like to know if this is doable and, if so, if there are any relevant references.

Thankyou.

html

<template for:each={swimlanes.Swimlane} for:item="dataItem">
  <div key={dataItem.OrchestrationPlan} class="slds-box slds-m-around_xx-small">
    <lightning-accordion allow-multiple-sections-open active-section-name={swimlanes.ActiveSections}>
      <lightning-accordion-section name={dataItem.OrchestrationPlan} label={dataItem.OrchestrationPlan}>
        <lightning-radio-group options={dataItem.Tasks} value={rollBackPlanId} variant="label-hidden"
          onchange={handleRadioChange} >
        </lightning-radio-group>
      </lightning-accordion-section>
    </lightning-accordion>
  </div>
</template>

js

 handleRadioChange(event) {
    this.rollBackPlanId = event.detail.value;
    this.disableRollbackBtn = false;
    console.log("this.label==>", event.detail);
    console.log("this.value==>", JSON.stringify(this.rollBackPlanId));
  }

1 Answer 1

0

Since you already have the value, you can easily find the related record:

const selectedIndex = this.swimlanes.Swimlane.findIndex(
  (swimlane) => swimlane.Id === event.detail.value
);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .