1

I am trying to set the data of the Lightning:Datatable from the wrapper class in server-side Controller.

    public class AccountWrapper{       
        @AuraEnabled public Account acct {get;set;}
        @AuraEnabled public boolean isSelected {get;set;}        
        @AuraEnabled public String errorMsg {get;set;}

        public AccountWrapper (Account acc, boolean b, String msg){
            acct = acc;  
            isSelected = b; 
            errorMsg = msg;
        }  
    }

When I am setting the value of the attribute

<aura:attribute name="data" type="List"/>

as :- component.set("v.data", response.getReturnValue().lstAcctWrapper);

But the problem is how we can distinguish the value in the column as rows coming blank.

<lightning:datatable
    keyField="id"
    data="{! v.data }"
    columns="{! v.columns }"
    hideCheckboxColumn="false"/>

enter image description here

1 Answer 1

3

You need to set the field definiation with data to make it work

cmp.set("v.columns", response.getReturnValue().ldwList);
cmp.set("v.data", response.getReturnValue().sobList);
cmp.set("v.fieldsList", response.getReturnValue().fieldsList);

and then need to use same in DataTable as well

<lightning:datatable
    columns="{! v.columns }"
    data="{! v.data }"
    keyField="{! v.keyField }"
    showRowNumberColumn="true"

You can find working example on my blog here: Lightning Data Table With Lazy Loading

You must log in to answer this question.

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