+ Start a Discussion
.12.12 

My aura iteration is not working properly inside a <tbody>

Here is my json i was using to iterate and display values in table form 

While i was trying to display only first array was keep on iterating second array values were not showing for me


For suppose if i'm trying to display ${!det.totalValue} from JSON

The Output i was getting like:-

6923.9346
6923.9346

But Expected Output should be like below:-

6923.9346
8923.9346

What i was missing code can any one explain me in details please.

Thanks in Advance

values= {"message": "Success","responseCode": 4000,"response": "Success","result": [{"accountType": "Savings","accounts": [{"accountName": "RAM REDDY","registrationId": 501049438,"details": [{"currentNumber": 12,"accountNumber": 12000012653,"bankName": "STATE BANK  BANK, KA","gender": "M","releaseAmount": "77.00","accountName": "RAM REDDY","totalValue": "6923.9346","registrationId": 501049438,"nominee": {"nomineeName": "RAJI REDDY","shortName": "RAJI"},"recieptId": "001","recieptDate": "12/12/2021"}]}]},{"accountType": "Savings","accounts": [{"accountName": "RAM GANESH","registrationId": 501049438,"details": [{"currentNumber": 13,"accountNumber": 3338359458,"bankName": "STATE BANK  BANK, KA","gender": "M","releaseAmount": "7237.00","accountName": "RAM GANESH","totalValue": "8923.9346","registrationId": 501023433,"nominee": {"nomineeName": "RASI REDDY","shortName": "RASI"},"recieptId": "23","recieptDate": "12/12/2021"}]}]}]}


<tbody>
<aura:iteration items="{!v.values}" var="result" indexVar="rowIndex">
                                <aura:iteration items="{!result.accounts}" var="acc" indexVar="rowIndex">
                                <aura:iteration items="{!acc.details}" var="det" indexVar="rowIndex">
                                            <aura:if isTrue="{!item.accountNumber== '!det.accountNumber'}">
                                                <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate">Yes</span>
                                                        </div>
                                                    </span>                            
                                                </td>
                                                <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate">${!det.totalValue}</span>
                                                        </div>
                                                    </span>                            
                                                </td> 
                                                <aura:set attribute="else">
                                                    <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate">No</span>
                                                        </div>
                                                    </span>                            
                                                </td>
                                                <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate"></span>
                                                        </div>
                                                    </span>                            
                                                </td>
                                                </aura:set>
                                            </aura:if>
                                        </aura:iteration>
                                    </aura:iteration>
                                </aura:iteration>
</tbody>

mukesh guptamukesh gupta
Hi ,

Please use below code:-
 
<tbody>
<aura:iteration items="{!v.values}" var="result" indexVar="rowIndex">
                                <aura:iteration items="{!result.accounts}" var="acc" indexVar="rowIndex">
                                <aura:iteration items="{!acc.details}" var="det" indexVar="rowIndex">
                                            <aura:if isTrue="{!item.accountNumber== det.accountNumber}">
                                                <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate">Yes</span>
                                                        </div>
                                                    </span>                            
                                                </td>
                                                <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate">${!det.totalValue}</span>
                                                        </div>
                                                    </span>                            
                                                </td> 
                                                <aura:set attribute="else">
                                                    <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate">No</span>
                                                        </div>
                                                    </span>                            
                                                </td>
                                                <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate"></span>
                                                        </div>
                                                    </span>                            
                                                </td>
                                                </aura:set>
                                            </aura:if>
                                        </aura:iteration>
                                    </aura:iteration>
                                </aura:iteration>
</tbody>

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh 
.12.12

Hlo mukesh gupta,

i've tried which you have given it is not working kindly check my json please i was getting an error in iteration not in aura:if 

 

Here is my json i was using to iterate and display values in table form 
While i was trying to display only first array was keep on iterating second array values were not showing for me
For suppose if i'm trying to display ${!det.totalValue} from JSON

The Output i was getting like:-

6923.9346
6923.9346


But Expected Output should be like below:-
6923.9346
8923.9346


What i was missing code can any one explain me in details please.

Thanks in Advance


values= {"message": "Success","responseCode": 4000,"response": "Success","result": [{"accountType": "Savings","accounts": [{"accountName": "RAM REDDY","registrationId": 501049438,"details": [{"currentNumber": 12,"accountNumber": 12000012653,"bankName": "STATE BANK  BANK, KA","gender": "M","releaseAmount": "77.00","accountName": "RAM REDDY","totalValue": "6923.9346","registrationId": 501049438,"nominee": {"nomineeName": "RAJI REDDY","shortName": "RAJI"},"recieptId": "001","recieptDate": "12/12/2021"}]}]},{"accountType": "Savings","accounts": [{"accountName": "RAM GANESH","registrationId": 501049438,"details": [{"currentNumber": 13,"accountNumber": 3338359458,"bankName": "STATE BANK  BANK, KA","gender": "M","releaseAmount": "7237.00","accountName": "RAM GANESH","totalValue": "8923.9346","registrationId": 501023433,"nominee": {"nomineeName": "RASI REDDY","shortName": "RASI"},"recieptId": "23","recieptDate": "12/12/2021"}]}]}]}


<tbody>
<aura:iteration items="{!v.values}" var="result" indexVar="rowIndex">
                                <aura:iteration items="{!result.accounts}" var="acc" indexVar="rowIndex">
                                <aura:iteration items="{!acc.details}" var="det" indexVar="rowIndex">
                                                <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate">Yes</span>
                                                        </div>
                                                    </span>                            
                                                </td>
                                                <td role="gridcell" tabindex="-1" data-label="Record Type Name">                            
                                                    <span class="slds-grid slds-grid_align-spread">
                                                        <div class="slds-truncate">                                        
                                                            <span class="slds-truncate">${!det.totalValue}</span>
                                                        </div>
                                                    </span>                            
                                                </td>
                                        </aura:iteration>
                                    </aura:iteration>
                                </aura:iteration>
</tbody>