0

component pseudo code

<aura:iteration var="PIW" items="{!v.objInfo}">
            <thead>
                <tr>
                    <th>
                        <button class="slds-button slds-button_icon slds-button_icon-border-filled" aria-pressed="true" title="Like" value ="{!PIW.recordIds}" onclick = "{!c.showHide}" />
                    </th>

                </tr>
            </thead>


</aura:iteration>  

js

showHide:function(component, event, helper) {
    var PIWrecord = event.target.value;
    console.log(PIWrecord);

Tried this too:

    showHide:function(component, event, helper) {
    var PIWrecord = event.currentTarget.value;
    console.log(PIWrecord);

The PIWrecord here returns '[object Object]'. The object which I expect to be returned is :

public class rapidApprovalWrapper
{
    @AuraEnabled
    public List<lightWeightObject> recordIds;
    @AuraEnabled
    public String ObjName;
    @AuraEnabled
    public Boolean selected = false ;
    @AuraEnabled
    public Boolean status = false;
}

but even if I do event.currentTarget.value.ObjName it returns null.

Am I missing something here? The onClick function should have the target value as the object right?

0

Try below code, It should work. Not sure its right approach or not, but it does work for me :) .

<div data-rid="{!PIW.recordIds}">
<button class="slds-button slds-button_icon slds-button_icon-border-filled" aria-pressed="true" title="Like" value ="{!PIW.recordIds}" onclick = "{!c.showHide}" />
</div>

In Helper (below code must be in component helper),

var clickedDiv = event.target;
var clickedRec = !$A.util.isEmpty(clickedDiv.dataset.rid) ? clickedDiv.dataset.rid : '';

Hope it'd help.

  • No it is not working for me. It is giving me blank string even though I have value in {!PIW.recordIds} – Sukrut Jul 18 '18 at 9:56
0

Try this?

<aura:iteration var="PIW" items="{!v.objInfo}">
                <thead>
                    <tr>
                        <th>
                            <div data-piw="{!PIW}" onclick="{!c.showHide}"/>
                                 <button class="slds-button slds-button_icon slds-button_icon-border-filled" aria-pressed="true" title="Like" value="someValue"/>
                            </div>
                        </th>
                    </tr>
                </thead>
    </aura:iteration>

CONTROLLERJS:

showHide : function(component, event, helper) {
        var selectedRow = event.currentTarget;
        var piw = selectedRow.dataset.piw;
        var recordIds = piw.recordIds;
        alert(recordIds);
    },

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.