I am trying to render multiple data tables on a page (inside lightning accordians but thats irrelevent) using Aura iteration. i am specifically having trouble with the data attribute of the datatable. i set that equal to the iteration variable (which is an object so it shouldnt be an issue) but that doesn't seem to be accessing the data correctly. The Name of the accordian section is rendering correctly in the accordianSection and console.logs should conList is being set correctly, any ideas


  <aura:attribute name="conList" type="List"/>
  <aura:attribute name="columns" type="List"/>
  <div class="slds-m-around_x-large">

    <lightning:accordion >
        <aura:iteration items="{!v.conList}" var="con">
            <lightning:accordionSection name="{!con.name}" label= 

                        columns="{! v.columns }"
                        onrowaction="{! c.handleRowAction }"



   doInit: function(component,event,helper){

    component.set('v.columns', [

            {label: 'Premium', fieldName: 'Premium_c__c', type: 'number'}


    var action = component.get('c.getContacts');
    action.setParams({ "rId": component.get("v.recordID") });
    action.setCallback(this, function(response){
        var state = response.getState();
        if(state === 'SUCCESS' && component.isValid()){
            //get contact list
           var intial= response.getReturnValue();
            component.set('v.conList', intial);

The con variable should just be an object with key:value pairs returned from my apex class and exactly what typically is used for the datatable so i am not positive why it doesnt seem to work

  • what attribute type is conList ? iirc, aura:iteration will only work for arrays (in this case, it should be an array or list of object(s))
    – glls
    Mar 22, 2019 at 18:28
  • Sorry didn't indent correctly but it is a list, the iteration works correctly as i am able to set the name correctly of the lightning accordian. I believe that lightning data table takes a list / array as well and that is the issue
    – Bobbygllh
    Mar 22, 2019 at 18:39
  • 1
    what does your response.getReturnValue() look like?
    – glls
    Mar 22, 2019 at 18:41
  • Have you tried doing this without a server round trip. Just create the data in the component directly and see if that works? Jul 23, 2019 at 15:02

1 Answer 1


You can do this if the Array you assign to the table contains Arrays with the data you want per iteration. So what i mean is that each object in the array needs to be put in an array of its own.

[[{firstName : 'john',lastName : 'doe'}][{firstName : 'jane',lastName : 'doe'}]]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .