Error -
My code -
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome"
access="global" controller="DisplayProductLinesController">
<aura:attribute type="Product_Lineitem__c[]" name="prodList"/>
<aura:attribute name="mycolumns" type="List"/>
<aura:attribute name="selectedprods" type="List" default=""/>
<aura:handler name="init" value="{!this}" action="{!c.fetchprod}"/>
<lightning:datatable data="{! v.prodList }"
columns="{! v.mycolumns }"
keyField="id"
hideCheckboxColumn="false"
onrowselection="{! c.getSelectedName}"/>
</aura:component>
HELPER -
({
fetchProdHelper : function(component, event, helper) {
component.set('v.mycolumns', [
{label: 'Id', fieldName: 'Id', type: 'text'},
{label: 'Prod Detail', fieldName: 'Prod_Detail__c', type: 'text'},
{label: 'Name', fieldName: 'Name', type: 'text'}
]);
var action = component.get("c.fetchProdLines");
action.setParams({
});
action.setCallback(this, function(response){
var state = response.getState();
if (state === "SUCCESS") {
component.set("v.prodList", response.getReturnValue());
}
});
$A.enqueueAction(action);
},
getSelectedName: function (component, event) {
var selectedRows = event.getParam('selectedRows');
for (var i = 0; i < selectedRows.length; i++){
alert("You selected: " + selectedRows[i].Id);
}
}
})
Where am I going wrong?
I tried to resolve this by adding <aura:if isTrue="{!v.errorMsg}"> to display error but it did not resolve the issue.