You need to sign in to do that
Don't have an account?
Lukesh Karmore
How to add columns dynamically in js file of aura component for lightning:datatable??
I have component where I can select field values from multiselect picklist and this field value should map automatically in column of datatable. I tried below
var fieldNames=component.get("v.fieldslabel");//list of selected fields from picklist console.log('****** '+fieldNames);
for (var i=0; i < fieldNames.length; i++) {
var column=[
{label: fieldNames[i],fieldName: fieldNames[i] }
]
}
component.set('v.columns', this.column);
can any one give me idea.Thanks ! value is visible when I inspect , but not in component.
var fieldNames=component.get("v.fieldslabel");//list of selected fields from picklist console.log('****** '+fieldNames);
for (var i=0; i < fieldNames.length; i++) {
var column=[
{label: fieldNames[i],fieldName: fieldNames[i] }
]
}
component.set('v.columns', this.column);
can any one give me idea.Thanks ! value is visible when I inspect , but not in component.
A similar ask was posted here: https://salesforce.stackexchange.com/questions/384098/how-can-i-make-lightningdatatable-columns-dynamic according to which
"If you have a dual list box, presumably your data is already in the form of:
[ { label: 'Option 1', value: 'Option1' }, ... ]
Which means you'd want to use the appropriate properties: "
Thanks