1

Is there a way to hide or render labels based on a true/false value? For example, how to hide only the Phone label but display the other two labels? Is there a possible render value that can be set?

({
   init: function (cmp, event, helper) {
        cmp.set('v.mycolumns', [
            { label: 'Contact Name', fieldName: 'Name', type: 'text'},
            { label: 'Phone', fieldName: 'Phone', type: 'phone'},
            { label: 'Email', fieldName: 'Email', type: 'email'}
        ]);
        helper.getData(cmp);
    }
})
1

label is not mandatory. You can just use below as column object:

{ fieldName: 'Phone', type: 'phone'},

added based on comments

You can filter the columns instead:

({  
    init: function (cmp, event, helper) {
        let columns = [
            { label: 'Contact Name', fieldName: 'Name', type: 'text'},
            { label: 'Phone', fieldName: 'Phone', type: 'phone'},
            { label: 'Email', fieldName: 'Email', type: 'email'}
        ];
        let mycolumns = columns.filter(col => col.label !== 'Phone');
        cmp.set('v.mycolumns',mycolumns);
        helper.getData(cmp);
    }
})
  • Is there a way to not set one of those columns based on a true of false value? If i only wanted to display the Contact and Email Column would it be possible? ideally I'm looking to see if there is something such as this: { fieldName: 'Phone', type: 'phone', rendered: true} – ebar Aug 12 at 14:13
  • we dont have rendered attribute but you can implement filter function. Added in answer – salesforce-sas Aug 12 at 14:23

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.