1

I'm defining a custom column for a Lightning dataTable component to hold a Lightning combobox like this:

{
    label: 'Down Payment Type',
    fieldName: 'DownPaymentType__c',
    type: 'picklistColumn',
    editable: true,
    typeAttributes: {
        placeholder: 'Choose Type',
        options: downPaymentTypeOptions,
        variant: 'label-hidden',
        value: {fieldName: 'DownPaymentType__c'}
    }
}

I'm defining the options in the same file, prior to the class definition, like this (with the intention of loading them dynamically once this is working):

const downPaymentTypeOptions = [
    {label: 'Cash', value: 'Cash'},
    {label: 'Trade', value: 'Trade'},
    {label: 'Both', value: 'Both'},
    {label: 'None', value: ''}
];

I have a custom component extending dataTable which accepts the column object above. It looks like this:

export default class CashTradeTable extends LightningDatatable {
    static customTypes = {
        picklistColumn: {
            template: customText,
            editTemplate: customPicklist,
            standardCellLayout: true,
            typeAttributes: ['name', 'label', 'placeholder', 'options', 'value', 'context', 'variant']
        }
    };
}

Here's the edit template (customPicklist):

<template>
    <lightning-combobox name="picklist"
                        data-inputable="true"
                        label={typeAttributes.label}
                        value={editedValue}
                        placeholder={typeAttributes.placeholder}
                        options={typeAttributes.options}
                        variant={typeAttributes.variant}>
    </lightning-combobox>
</template>

However, while properties like placeholder and variant work properly, options does not. I've also realized that value isn't transferring to the edit template either, regardless of whether I assign typeAttributes.value or editedValue.

Note that only the editTemplate values aren't being updated. If I substitute the edit template for the standard template it's working--the options are populated. I need the options to populate in the edit template.

I've tried using a getter in the class with no improvement. I have checked the value of the columns object in the main component and the options value is correct.

The thing looks like this initially:

enter image description here

And like this in edit mode:

enter image description here

I've also verified that it's not a truncation/obscured view thing; I can see that the dropdown element is empty. Why aren't the values populating?


Related resources:

0

1 Answer 1

1

The answer was found in a repository for a custom component. Apparently I needed to reference columnDef in my attribute values, as:

options={columnDef.typeAttributes.options}

This was not indicated in any Salesforce documentation or other discussions I encountered, but it resolved my options and value issues. Oddly, this wasn't necessary for label, placeholder, etc., though it also works for them.

You must log in to answer this question.

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