New Table Component dynamic column labels, dynamic readOnly?

Hi!
I'm working through the new table component and our api returns data based on a user's profile permission set. If the profile doesn't have access to a field it won't get returned in the query, otherwise the data is returned with a field value and whether it's read only for them, example below:

{
    Email: {
        fieldValue: "someone@myemail.com",
        readOnly: false
    },
    Job_Function__c: {
       fieldValue: "Operations",
       readOnly: true
    }
}

The table does a fairly decent job of predicting the column labels based on field name but with our custom fields in salesforce ending in __c we end up seeing "Job function c" and have to go in and manually edit them to be user friendly. In a list view I'm able to reference the value of the item at index "i" and apply some javascript to format it accordingly so I'm wondering if it's possible to have that same ability in the table? The closest I've come to being able to do that is to use {{Object.keys(self.selectedSourceRow)[0]}} but the index is hardcoded so I have to know how many fields are returned for a profile, which ideally I wouldn't need to know.

The next thing is to dynamically set whether a column is editable. From above our api does return that value. However, once you set the mapped value to {{item.fieldValue}} (in our case) "item" is then the mapped value and no longer (again in our case) the object that that is the value of the Email key, so I'm not also able to set editable to {{item.readOnly}}. Instead I've had to have knowledge of what it is again and use {{currentSelectedRow.Email.readOnly===false}}. Here either continued access to item or some kind of ability to use the value of readOnly on the field at index "i" would be helpful, or please let me know if I'm missing the functionality that exists and would accomplish this.
image

Hi @ktbg, thanks for your feedback!

For your first question, the column editor currently does not expose the source key, so the label must be manually updated. The team will look into adding better heuristics for the auto-name generation to ignore suffixes like __c to reduce the amount of manual work required for column names with this type of format.

For the second question, including a reference to column key as you do in {{currentSelectedRow.Job_Function__c.readOnly===false}} is currently the best way to accomplish this, as the editor does not expose any data that would allow you to derive Job_Function__c programmatically.

These workarounds should hopefully solve what you're looking for! The team is currently looking into dynamic column support for the new Table, and in the meantime dynamic column settings are still accessible in the legacy table if you need them. Stay tuned for further improvements here!

1 Like