I'm dynamically creating a table in JS Controller using lightning:datatable and it works fine. In the below code I am assigning the column label which comes as column header a static value like, label: "Customer Id", label: "Customer Name" etc. I would like to assign an aura attribute value instead of a static string. How can I achieve this?
//CODE
({
COULMNS: [
*//Need to set the label as an attribute(dynamic value) instead of static value here "Customer Id"*
{ label: "Customer Id",fieldName: "customerId", type: "text" },
{ label: "Customer Name",fieldName: "customerName", type: "text" },
{ label: "Month1",fieldName: "month1Val", type: "text" },
{ label: "Month2",fieldName: "month2Val", type: "text" },
{ label: "Month3",fieldName: "month3Val", type: "text" }
],
showTableVal: function(component,id) {
$A.createComponent("lightning:datatable", {
keyField: "Id",
data: tableData,
columns: component.get("v.columns"),
hideCheckboxColumn: true
},
(content, status) => {
if (status === "SUCCESS") {
component.set('v.body', [content]);
component.find("overlayLib").showCustomModal({
header: "Sales Analysis",
body: content,
showCloseButton: true,
closeCallback: function() {
// alert("You closed the alert!");
}
})
}
});
},
})*