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
Manoj Kumar 813Manoj Kumar 813 

Hi Can any one help me on scenarion?

I would like to design account lwc component where I will be using record id passed from another component .
The component will be in view moved and on clicking edit button it will show the fields in editable mode and on cancel it will render to previous value.Only wire service need to be used.
 
AbhishekAbhishek (Salesforce Developers) 
Hi,

I have a suggestion and posting the sample code.

I have two lightning components:

First component:

<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>



For this, I 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}" />
Hope this will answer your question.

Kindly mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Thanks.