4

I have a custom LightningDatatable and I'm passing some typeAttributes to my component. Problem is, the last field is never being passed along my component.

customdatatable.js

export default class CustomDatatable extends LightningDatatable {
    static customTypes = {
        lookup: {
            template: LookupTemplate,
            typeAttributes: ['uniqueId', 'objectType', 'icon', 'label', 'displayFields', 'displayFormat', 'valueId', 'filters', 'additionalSearchField', 'editable', 'fieldName', 'extraField']
        }
    };
}

lookupTemplate.html

<template>
    <c-lookup-lwc editable={typeAttributes.editable} unique-key={typeAttributes.uniqueId}
        obj-name={typeAttributes.objectType} icon-name={typeAttributes.icon} label-name={typeAttributes.label}
        display-fields={typeAttributes.displayFields} display-format={typeAttributes.displayFormat}
        value-id={typeAttributes.valueId} field-name={typeAttributes.fieldName} extra-field={typeAttributes.extraField}
        additional-search-field={typeAttributes.additionalSearchField}>
    </c-lookup-lwc>
</template>

lookupLwc.js

export default class LookupLwc extends LightningElement {

    @api extraField;
    ...
}

In my lookupLwc component, all my fields such as editable and displayFields are populated correctly, but the last field, extraField is always undefined. Whichever property I put at the end in the typeAttributes in customdatatable.js is always undefined, so I'm wondering if there are a maximum number of properties you can pass?

4
  • Hey, just crossed this issue, looks like the number of attributes per custom template is limited at 11 or 12. Only workaround is to create an other template under it..Thanks though ;)
    – AshBringer
    May 31 at 0:30
  • No it's not limited, I remember having a bug somewhere which caused the issue.
    – ViqMontana
    May 31 at 7:45
  • I am also running into this issue. @ViqMontana is there a workaround for the bug causing this? Jun 1 at 21:23
  • @Timestretch post your question as a new question
    – ViqMontana
    Jun 2 at 7:10

1 Answer 1

0

Late on the response to this, but there seems to be an undocumented limit on the number of typeAttributes you can pass into a custom datatable cell. The limit appears to be 11 or 12. I was able to work around this by wrapping my type attributes in an object, passing it to the cell, and then unwrapping the properties I needed in the cell's controller.

1
  • Interesting! Could you provide some example code? Aug 5 at 20:14

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.