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 Answer 1

2

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);
    }
})
2
  • 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
    Commented Aug 12, 2019 at 14:13
  • we dont have rendered attribute but you can implement filter function. Added in answer Commented Aug 12, 2019 at 14:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .