You need to sign in to do that
Don't have an account?
.12
how to use aura if to match two values from aura iteration
What if i have two json files i have to use aura if and match two values and show YES if two values were matching if not matching have to show else NO how it is possible can any one explain if possible
Because i've tried the below code but it is not working and always displaying only else part
<aura:if isTrue="{!firstjson.firstName== '!secondjson.firstName'}" >
<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>
<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>
</aura:set>
</aura:if>
Because i've tried the below code but it is not working and always displaying only else part
<aura:if isTrue="{!firstjson.firstName== '!secondjson.firstName'}" >
<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>
<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>
</aura:set>
</aura:if>
I've tried which you have given it is not working exactly
Here is the code in second iteration i was comparing the firstName and setting the value in third and fourth column that's the thing i was checking if you know please help me out
In the first iteration i have some values in json and in second also i have some values in json which will match in first json so comparing those values i was trying to set the values in second iteration of third and fourth column of the table
And sorry i was not able to past the entire code is saying that limit of 32000 charachters were exceeded
<aura:component controller="ListController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickActionWithoutHeader,lightning:availableForFlowScreens" access="global" >
<aura:handler name="init" value="{! this }" action="{! c.loadOptions }"/>
<aura:handler name="init" value="{! this }" action="{! c.loadValues }"/>
<aura:handler name="init" value="{! this }" action="{! c.loadspValues }"/>
<aura:attribute name="options" type="sObject"/>
<aura:attribute name="values" type="sObject"/>
<aura:if isTrue="{!not(empty(v.options))}">
<div class="slds-table_header-fixed_container">
<div class="slds-scrollable_y" style="width:100%">
<table role="grid" aria-rowcount="2" class="slds-table slds-table_header-fixed slds-table_bordered slds-table_edit" style="table-layout:fixed;width:100%">
<thead>
<tr class="slds-line-height_reset">
<th scope="col" tabindex="-1" aria-label="Account Number" style="width:15%">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">First Name</span>
</span>
</div>
</th>
<th scope="col" tabindex="-1" aria-label="Fund Name" style="width:30%">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">Last Name</span>
</span>
</div>
</th>
<th scope="col" tabindex="-1" aria-label="Current Value" style="width:13%">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">Yes/No</span>
</span>
</div>
</th>
<th scope="col" tabindex="-1" aria-label="Current Value" style="width:13%">
<div class="slds-cell-fixed" style="width: 150px;outline:none;">
<span class="slds-th__action">
<span class="slds-truncate">Phone Number</span>
</span>
</div>
</th>
</tr>
</thead>
<tbody>
<aura:iteration items="{!v.options}" var="item" indexVar="rowIndex">
<tr data-data="{!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">{!item.firstName}</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">{!item.lastName}</span>
</div>
</span>
</td>
<aura:iteration items="{!v.values}" var="result" indexVar="rowIndex">
<aura:if isTrue="{!item.firstName== '!result.firstName'}">
<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">${!result.phoneNo}</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>
</tr>
</aura:iteration>
</tbody>
</table>
</div>
</div>
</aura:if>
</aura:component>
Thanks in Advance
Please use below steps:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Thanks for the reply i've tried which you have sent sorry to say it is also now working
In the first iteration i have some values of frist json and in second also i have some values in json which will match in first json so comparing those values i was trying to set the values in second iteration of third and fourth column of the table
Here are my two jsons i'm providing
options = {"accountName": "RAM REDDY","registrationId": "501049438","accountType": "Savings","openDate": "08/24/2021","allowedTransactions": ["Send","Recieve","Manage"],"address": {"addressLine1": "","addressLine2": "","addressLine3": ""},"stocks": [{"stock": "BTC","stockName": "Bitcoin","stockNumber": "051","accountNumber": "12000012653","currentValue": "161293.80","totalShare": "5367.514", "totalCost": "134931.56089999998","minimumInvestment": "200.000000000000"},{"stock": "LTC","stockName": "Litecoin","stockNumber": "052","accountNumber": "3338493","currentValue": "324.80","totalShare": "545.514", "totalCost": "2242.56089999998","minimumInvestment": "50.000000000000"}],"accountClosedStatus": false,"totalCurrentValue": 170790.31}
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.options.stocks}" var="item" indexVar="rowIndex">
<tr data-data="{!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">{!item.accountNumber}</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">{!item.stockName}</span>
</div>
</span>
</td>
<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>
</tr>
</aura:iteration>
</tbody>