pozil / sfdc-ui-lookup-lwc

Salesforce Lookup Component built with Lightning Web Components.
Apache License 2.0
578 stars 223 forks source link

Use in Lightning Datatable #130

Closed banderson-stripe closed 1 year ago

banderson-stripe commented 1 year ago

@pozil I was able to get the Lookup to function correctly by using it in a editTemplate as defined in the Custom Data Type.

image

However, I did need to add a public API method to the lookup.js file called validity() as defined in the Custom Data Type documentation above:

@api
get validity() {
    return true;
}

I am just returning true since I can't think of any validations for my use case.

pozil commented 1 year ago

Just added this public property in the latest release v2.20.0.

banderson-stripe commented 1 year ago

@pozil just wanted to update you on this. So I had add to do something extra to the validity() function:

get validity() {
    return {valid:!this._errors || this._errors.length === 0};
}

Also, when using in a Custom Data Type for lightning-datatable, there has to be an API value() method for Salesforce's internal datatable code so it can populate the draftValues correctly:

@api
get value()
{
    return this._curSelection;
}