I am fetching UserLicenses data and binding into the lighting dataTable, data is coming fine from the apex controller but not display in the lighting:dataTable.
Apex Controller:
@AuraEnabled
public static List<String> getLicenseInfo(){
List<string> ulList = new List<string>();
for(UserLicense ulObj : [SELECT Name,Status,TotalLicenses,UsedLicenses FROM UserLicense]){
ulList.add(ulObj.Name);
ulList.add(ulObj.Status);
ulList.add(string.valueOf(ulObj.TotalLicenses));
ulList.add(string.valueOf(ulObj.UsedLicenses));
}
return ulList;
}
Cmp:
<aura:component controller="ConfigMonitoring" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:attribute name="recordId" type="UserLicense" />
<aura:attribute name="UserLicenses" type="UserLicense[]"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:attribute name="tableCols" type="List" />
<lightning:card title="User Licenses Org-wide" class="container" >
<lightning:datatable data="{!v.UserLicenses }"
columns="{!v.tableCols }"
keyField="Id"/>
</lightning:card>
</aura:component>
Controller.JS
({
doInit : function(component, event, helper) {
var cols = [
{label: 'licenseName', fieldName: 'Name', type: 'text'},
{label: 'licenseStatus', fieldName: 'Status', type: 'text'},
{label: 'TotalLicenses', fieldName: 'TotalLicenses', type: 'text'},
{label: 'UsedLicenses', fieldName: 'UsedLicenses', type: 'text'}
];
component.set("v.tableCols", cols);
helper.getLicense(component);
}
})
Helper.JS
({
getLicense : function(component) {
var action = component.get("c.getLicenseInfo");
var self = this;
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS") {
var storeResponse = response.getReturnValue();
component.set("v.UserLicenses",response.getReturnValue());
alert(storeResponse);
}
});
// enqueue the Action
$A.enqueueAction(action);
}
})