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
shivram survaseshivram survase 

Hi,I wanted to excute inner <aura:if> only once.I'm unable to set the attribute value to false.Help is appreciated.

<aura:attribute name="native" type="boolean" default="true"/>
    <aura:attribute name="accounts" type="Account[]"/> 
    <div class="pink">
    <table style="width:100%">
        <aura:iteration var="acc" items="{!v.accounts}">
            <aura:if isTrue="{!acc.Id != ' '}">
            <aura:if isTrue="{!v.native}">
            <tr>
                <th>Account Id</th>
                <th>Name</th>
                <th>Country</th>
                <th>City</th>
                <th>Email</th>
            </tr>
                {!v.native}=false;
                 component.set("v.native",'false');
                 {!v.native};

            </aura:if>
            <tr>
                <td>{!acc.Id} </td> 
                   <td>{!acc.Name} </td> 
                   <td>{!acc.Country__c} </td>
                   <td> {!acc.City__c} </td>
                   <td>{!acc.Email__c}</td>            
            </tr>
            </aura:if>
      </aura:iteration>
    </table>  
    </div>

I wanted to set "native" attribute to false  without using the client controller.If anyone having another solution to this problem.
Please share it.
BDatlaBDatla
Hi ,
Can you please try to change 'false' to false if the native is not string type ?
Please let me know the result.

Reagrds,
BDatla
shivram survaseshivram survase
It doesn't work.Unable to change the value from 'true' to 'false'.Is there any solution to excute <aura:If> only once.
I wanted to view <th> (table header) only once.
RishavRishav
Hii shivram,

You are doing mistake in your code  in this line ,
  {!v.native}=false;
  component.set("v.native",'false');

your both of above line won't work inside component directly.  
In .cmp file only HTMl, and expression will work but u can't use this method inside the .cmp file.
if you want to  change the value of your attribute u need to do this using controller , define an event call the javascript code and change the value of  your attribute.

For your query of getting header element only once i did this coding :
<aura:component controller="OpportunityController">
    <aura:attribute name="opportunities" type="Opportunity[]"/>
    <aura:attribute name="check" type="Boolean" default="true"></aura:attribute>
    
    <ui:button label="Get Opportunities" press="{!c.getOpps}"/>
      <table>
         <tr>
          <th><b>Name</b></th>
          <th><b>Close Date</b></th>  
          <th><b>Owner</b></th>
          <th><b>Stage Name</b></th>
          </tr>       
              <aura:iteration var="opportunity" items="{!v.opportunities}">
                   <tr style="color:red;">
                       <td>{!opportunity.Name}</td> 
                       <td>{!opportunity.CloseDate}</td>
                       <td>{!opportunity.Owner.Name}</td>
                       <td>{!opportunity.StageName}</td>
                   </tr>    
                </aura:iteration>
             
    </table>
</aura:component>
 And my below screenshot is the result.

this is the result
i have not added much CSS but u can do .

If your problem  solve please close this thread by clicking on best answer. 
If you have any further doubt on this then please let me know.

Thanks
Rishav Kumar
 
shivram survaseshivram survase
Hi Rishav,
I really appreciate your help.But i want to change the value of attribute on the .cmp file itself without using the client controller .
Anything else do you want to suggest?
RishavRishav
I know only one thing before doing anything we need to understand the basics of that. If we are clear with that then we can go ahead. 
I don't know anything beyond this, so can't suggest you 
Ramesh KallooriRamesh Kalloori
Hi Rishav,

Please update the code as below it is working for me.
 
<aura:iteration var="acc" items="{!v.accounts}" indexVar="index">
            <tr hidden="{!if(index==0,false,true)}">
                <th>Account Id</th>
                <th>Name</th>
                <th>Country</th>
                <th>City</th>
                <th>Email</th>
            </tr>
                {!v.native}=false;
                 component.set("v.native",'false');
                 {!v.native};
            </aura:if>
            <tr>
                <td>{!acc.Id} </td> 
                   <td>{!acc.Name} </td> 
                   <td>{!acc.Country__c} </td>
                   <td> {!acc.City__c} </td>
                   <td>{!acc.Email__c}</td>            
            </tr>
            </aura:if>
      </aura:iteration>

Let me know if you still have any problems with this.

If your problem solve please close this thread by clicking on best answer. 

Thanks,
Ramesh
LinkedIn: https://www.linkedin.com/in/kallooriramesh/