function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sachin Bhalerao 17Sachin Bhalerao 17 

How can i use Lightning group:radio button in Component file?

Dear Team ,

Greetings !!!

How can i use Lightning group radio button in Component file of Lightning component . How can i bind radio button with piclist in custom object .
<aura:component controller="BISPController">
	        <aura:attribute name="NewCon" 

            type="Questions__c"

            default="{ 'sobjectType': 'Questions__c',

                     
                     
                     'Does_Lightning_Component_uses_Javascript__c	' : '',
                     
                     'Which_file_not_part_of_lightning_comp__c' : '',}" />
    
      <form>
                 <div class="slds-form-element">
          <div class="slds-form-element__control">
              <label class="slds-form-element__label" for="form-element-01">Does Lightning Component uses Javascript</label>
            <div style="background-color:white; height:33px; border:solid; border-color:rgb(217,219,221); border-radius:4px;">
                  <force:inputField value="{!v.NewCon.Does_Lightning_Component_uses_Javascript__c}" class="form-control" />
              </div>
               
    </div>
  </div>  
          
          <div class="slds-form-element">
          <div class="slds-form-element__control">
              <label class="slds-form-element__label" for="form-element-01">Which file not part of lightning comp</label>
            <div style="background-color:white; height:33px; border:solid; border-color:rgb(217,219,221); border-radius:4px;">
                  <force:inputField value="{!v.NewCon.Which_file_not_part_of_lightning_comp__c}" class="form-control" />
              </div>
               
    </div>
  </div>      
          
          <div>
                          <ui:button label="Save" press="{!c.save}"/>
          </div>
           </form>
    
</aura:component>

 
Soyab HussainSoyab Hussain
Hi Sachin,

Use this link this will help you:
Use picklist field in lightning radio group (https://www.biswajeetsamal.com/blog/get-picklist-values-dynamically-in-lightning-radio-group-component/)

Regards
Soyab
Ajay K DubediAjay K Dubedi
Hi Sachin,
 
According to your requirement, I have got an example. In this example, I have made two options in radio button - (1) Agent  (2) Agency
 
//This attribute is for options radio options.

 <aura:attribute name="options" type="List" default="[

       {'label': 'Agent', 'value': 'Agent'},
       {'label': 'Agency', 'value': 'Agency'},
       ]"/>

//Here I have chosen none option by default, You may choose Agent or Agency(Inside the default Quotes)

  <aura:attribute name="optionChoosenRadio" type="String" default=""/>




 <div class = "slds-col slds-size--2-of-2 " style="display: inline;">
 <lightning:radioGroup name="radioGroup"
    label="Choose Option"
    variant="label-inline"
    options="{! v.options }"
    value="{! v.optionChoosenRadio }"
    type="radio"
    required="true" onchange="{!c.handleChange}"  />
</div>



// Controller- write the code here, what you want to perform after chosen the radio option.

     handleChange: function (c, e,h) {
        console.log('Inside controller--> handleChange');
       
        },

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sachin,

Greetings to you!

I have posted the code earlier on one of the forum's question. Please refer to the below link.

https://developer.salesforce.com/forums/?id=9062I000000g7qwQAA

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas