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.

    data="{! v.data }"
    columns="{! v.columns }"

enter image description here


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

    columns="{! v.columns }"
    data="{! v.data }"
    keyField="{! v.keyField }"

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

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.