I have an attribute of type integer.
<aura:attribute name="selectedRowNum" type="integer" />
I also have an iteration component in which I get the index of the current object that is being iterated through javascript, code is below on how I get that
var selectedItem = event.currentTarget; // Get the target object
var index2 = selectedItem.dataset.record; // Get its value i.e. the index This is because in the iterration i used index on it
var selectedacc = component.get("v.Accounts")[index2]; // Use it retrieve the stored record
I then store the index in the integer attribute
var selectedRowNum = component.get("v.selectedRowNum");
var number = component.get("v.index");
component.set("v.selectedRowNum", number);
This is my following code in the lightning component that I am having trouble with
<aura:iteration var="account" items="{!v.Accounts}" indexVar="idx">
<tr class="slds-hint-parent">
<th role="gridcell">
<div class="slds-truncate" title="Acc"><a href="{!'/'+ account.Id }" target="_blank" tabindex="-1">{!account.Name} {!idx == v.selectedRowNum} <p>{!v.selectedRowNum} + {!idx} +{!v.index} </p></a></div>
</th>
<td role="gridcell">
<lightning:layoutItem size="4">
<div>
<aura:if isTrue = "{!idx == v.selectedRowNum}">
<!-- show nothing if the row is selected -->
<aura:set attribute="else">
<c:customLookupComp objectAPIName="Master_Customer__c"
iconName="standard:account"
selectedRecord="{!v.selectedLookUpRecord}"
label="Search"
fieldAPIName="Id"
resultField1="Master_Customer__c"
resultField2=""
showlabel="false"
/>
<force:inputField value="{!v.selectedLookUpRecords}"/>
</aura:set>
</aura:if>
</div>
</lightning:layoutItem>
</td>
As you can see I output what the current values of the index of the iteration component and the attribute. They match... But the aura if comparasion comes out false..
so !idx == v.selectedrownum always comes out false even though they show the same two numbers. I believe the data types are not the same and that is why the compare fails. If I were to hardcore the selectedrownum with a 0 then the aura if is valid( only for the index 0 for obvious reasons). Can I get some help on make sure these javascript integers match the integers the iteration component outputs? Has anyone else ran into this issue?
Thanks
type="Integer"
instead oftype="integer"
<aura:if isTrue="{!equals(v.selectedRowNum, idx)}" />