1

I have two lightning components:

firstcomponent:

<aura:component controller="ActionController"  implements="force:hasRecordId,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:lightningQuickAction" access="global">
    <aura:attribute name="theId" type="String"/>
    <aura:attribute name="options" type="String[]"/>
    <aura:attribute name="wrplst" type="WrapperCriteria[]"/>
    <aura:attribute name="selectedValue" type="String"/>
    <aura:handler name="deleteJob" event="c:deleteJobEvt" action="{!c.RemoveClick}" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <p>
       <b>Creating Action Criteria </b>
    </p>
    <h3 class="slds-section-title--divider">
       <b>
           <I> Action Criteria</I>
       </b>
    </h3>
    <table >
        <tr class="slds-text-title--caps">
           <th class="head">
               <I>Action</I>
           </th>
           <th class="head">
               <I>Object Name</I>
           </th>
           <th class="head">
               <I>Component</I>
           </th>
           <th class="head">
               <I>Operator</I>
           </th>
           <th class="head">
               <I>Special Operator</I>
           </th>
           <th class="head">
               <I>Special Operator * Value</I>
           </th>
           <th class="head">
               <I>Special Operator / Value</I>
           </th>
     </tr>
     <aura:renderIf isTrue="{!v.wrplst.length > 0}">
        <c:NewAction options="{!v.options}" selectedValue="" />
        <aura:iteration items="{!v.wrplst}" var="a">
            <c:NewAction wrp="{!a}"/>
         </aura:iteration>
     </aura:renderIf>
</table>
<lightning:button variant="brand" label="Add row" onclick="{!c.AddRow}" />
<lightning:button variant="brand"  label="Save" onclick="{!c.saveRow}" />

NewAction

<aura:component controller="ActionController" >
    <aura:attribute name="wrp" type="WrapperCriteria[]"/>
    <aura:attribute name="idval" type="String"/>
    <aura:attribute required="true" name="options" type="String[]"/>
    <aura:attribute required="true" name="selectedValue" type="String"/>
    <aura:attribute name="wpchange" type="List" />
    <aura:registerEvent name="deleteJob" type="c:deleteJobEvt"/>

    <tr>
        <td class="cell" style="padding-top:14px;padding-bottom:0px;">
           <p >
              <button type="button" onclick="{!c.RemoveClick}" >remove</button>
           </p>
       </td>
       <td class="cell" >
           <p>
               <lightning:select name="mySelect" label=" " value="{!v.selectedValue}" onchange="{!c.dosomething}">
                    <aura:iteration items="{!v.options}" var="item">
                        <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
                    </aura:iteration>
               </lightning:select> 
           </p>
      </td>
      <td class="cell" >
           <lightning:select name="select" label=" " aura:id="o" >
                <option value="">None</option>
           </lightning:select>
       </td>
       <td class="cell" >
           <p>
               <lightning:select name="selectItem" label=" ">
                   <option value="None">None</option>
                   <option value="+ Addition">+ Addition</option>
                   <option value="- Subtract  ">- Subtract</option>
                   <option value="* Multiply ">* Multiply</option>
                   <option value="/ Divide">/ Divide</option>
               </lightning:select>
           </p>
      </td>
      <td class="cell" >
          <p>
              <lightning:select name="selectItem" label=" " >
                  <option value="None">None</option>
                  <option value="*">*</option>
                  <option value="*/">*/</option>
                  <option value="/">/</option>
              </lightning:select>
          </p>
      </td>
      <td class="cell"  style="padding-top:14px;padding-bottom:0px;">
          <p>
              <ui:inputText value="{!v.wrp.specialOperatorValue}"/>
          </p>
      </td>
      <td class="cell"  style="padding-top:14px;padding-bottom:0px;">
          <p>
              <ui:inputText value="{!v.wrp.specialOperatorSlashValue}"/>
          </p>
      </td>
  </tr>

Questions:

  • How can pass record Id FROM FIRST COMPONENT TO NEW aCTION?
  • How can I pass Lightning OPTIONS VALUE FROM FIRST COMPOENT TO NEWaCTION?
  • WHERE iVE TO write that logic...Right now I had written outside the aura:iteration tag in first component.

I have attached Lightning select option image it shows values in only one row. please check the image.

image

6
  • For this, you have created an attribute <aura:attribute name="idval" type="String"/> use this to pass id to NewAction like this <c:NewAction options="{!v.options}" selectedValue="" idval="{!v.id}" /> Mar 29, 2017 at 8:51
  • But It gives problem in displaying the ligttning select option values in the table,...Please check the image Mar 29, 2017 at 8:55
  • Thanks @itzmukeshy7...I had written like this <c:NewAction wrp="{!a}" options="{!v.options}" selectedValue="" />.It resolves my issue Mar 29, 2017 at 9:00
  • You are sending values to same component avoid using two times <c:NewAction wrp="{!a}"/> <c:NewAction options="{!v.options}" selectedValue="" /> instead you use single ref <c:NewAction wrp="{!a}" options="{!v.options}" selectedValue="" />
    – vignesh
    Mar 29, 2017 at 9:01
  • @itzmukeshy7 You should add this as an answer to close this post. Mar 29, 2017 at 9:13

1 Answer 1

2

For this, you have created an attribute:

<aura:attribute name="idval" type="String"/>

use this to pass id to NewAction like below:

<c:NewAction options="{!v.options}" selectedValue="" idval="{!v.id}" />
0

You must log in to answer this question.

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