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
Hm_inviHm_invi 

get the id and field values from aura iteration table?

Hi, i have created a aura table with case fields in it.
no i want to find the id and and values of the row when i click on the case number. 
iam able to find the id using "event.currentTarget.dataset.recordid" but not the field values.
how can i also get the field values as they are already in the instance.
i made a server call to apex but it is only happening after firing the event. 
how to solve this?
<table id="tableId" class="slds-table slds-table_bordered slds-table_cell-buffer" cellspacing="1"  >
            <thead>
                <tr>
                    <th>Case Number</th>
                    <th>Subject</th>
                    <th>Created Date</th>
                </tr>
            </thead>
            <tbody>
                <aura:iteration items="{!v.filterlstCases}" var="cas">
                    <tr >
                        <td onclick="{!c.handleRowAction}" data-recordid="{!cas.Id}">
                            <a>{!cas.CaseNumber}</a>  
                        </td>
                        <td onclick="{!c.handleRowAction}" data-recordid="{!cas.Id}">
                            <a>{!cas.Subject}</a>  
                        </td>
                        <td>
                            <lightning:formattedDateTime value="{!cas.CreatedDate}" year="numeric" month="numeric" day="numeric"  hour="2-digit" minute="2-digit" hour12="false"/>
                        </td>
                    </tr>
                </aura:iteration>  
            </tbody>
        </table>
 
handleRowAction : function(component, event, helper){
        var selectedItem = event.currentTarget;
        var recordId = selectedItem.dataset.recordid;

//call to apex

       var getCaseAction = component.get("c.fetchCaseDetails");
        getCaseAction.setParams({
            'fetchId': recordId
        });
        getCaseAction.setCallback(this, function(response){
            var actionState = response.getState();
            
            if(actionState == 'SUCCESS') {
                console.log(response.getReturnValue());                 
            }
        });
        $A.enqueueAction(getCaseAction);
       
 //event call

        var evt = $A.get("e.c:myCasesDetailsEvent");
        evt.setParams({
            "caseIdfromChild" : recordId            
        });
        evt.fire();
        
    }
 
public class portalCases {
@AuraEnabled
    public static list<Case> fetchCaseDetails(string fetchId) {        
        list<case> detailList = [SELECT CaseNumber, Subject, CreatedDate, Status,origin FROM Case WHERE id= :fetchId];
        system.debug(detailList);
        return detailList;
        
    }
}

 
Best Answer chosen by Hm_invi
Hm_inviHm_invi
Found the solution.
might be helpful to someone.
Try this

Component changes
<td onclick="{!c.handleRowAction}" data-recordid="{!cas.Id + ':' + cas.CaseNumber +':' + cas.Subject + ':' + cas.CreatedDate}">

js
handleRowAction : function(component, event, helper){
    var selectedItem = event.currentTarget;
    var recordId = selectedItem.dataset.recordid;
    var record = recordId.split(':');

    //record[0] is Id
    //record[1] is CaseNumber
    //record[2] is Subject
    //record[3] is CreatedDate

 

All Answers

Hm_inviHm_invi
Found the solution.
might be helpful to someone.
Try this

Component changes
<td onclick="{!c.handleRowAction}" data-recordid="{!cas.Id + ':' + cas.CaseNumber +':' + cas.Subject + ':' + cas.CreatedDate}">

js
handleRowAction : function(component, event, helper){
    var selectedItem = event.currentTarget;
    var recordId = selectedItem.dataset.recordid;
    var record = recordId.split(':');

    //record[0] is Id
    //record[1] is CaseNumber
    //record[2] is Subject
    //record[3] is CreatedDate

 
This was selected as the best answer
Prashant Kumbhar 7Prashant Kumbhar 7
how will I retrieve thr record id from the data set ?
What is the data type of var record