Sarveshgithub / sfdc-lwc-lightning-datatable

Salesforce Lighting Data table
MIT License
78 stars 28 forks source link

[ Enhancement ] - Lookup as custom datatype #167

Closed mickaelgudin closed 1 year ago

mickaelgudin commented 1 year ago

It appears to be possible : https://github.com/jangidyogi94/SFDC-Recipes/tree/Lookup-in-Lightning-Datatable/src/lwc

I think I will implement it before the promotion of the repo since it's often needed.

Can you assign me this issue?

Sarveshgithub commented 1 year ago

that's a good enhancement

Sarveshgithub commented 1 year ago

Hey, @mickaelgudin Wish you a Happy new year. any luck on this enhancement

mickaelgudin commented 1 year ago

Hey @Sarveshgithub, happy new year !

I started an implementation for this enhancement, I hope it'll be done by the end of this month

mickaelgudin commented 1 year ago

@Sarveshgithub Almost done,

I fixed an issue that I found while testing : custom datatypes draft values were not merge with draft values of standard types.

The only remaining issue is that when the focus is lost(we click on another cell) the lookup or the picklist cells should come back to normal cell display style. It wasn't a big deal when it was regarding only the picklist custom datatype, but since the lookup pops over it become neccessary.

Sarveshgithub commented 1 year ago

Hey @mickaelgudin thanks for opening PR, I have tested some scenarios - found some issues Input Data Object - Contact Cols - FirstName,Account.Name,LastName,Level__c,CreatedDate Customized col JSON - { "Account.Name": { "label":"Account Name", "editable":true, "type":"lookup", "typeAttributes":{ "placeholder": "Choose Account", "objectApiName": "Contact", "fieldName": "AccountId", "label": "Account", "value": { "fieldName": "AccountId" }, "context": { "fieldName": "Id" }, "variant": "label-hidden", "name": "Account", "fields": ["Account.Name"], "target": "_self" } } }

Note : Level__c is picklist

  1. I have added "editable":true on col customized json to enable the standard edit icon it shows two icons( lookup custom icon and datatable icon ), can we utilize standard icon, on click of edit fire event to enable lookup.

    image
  2. save functionality not working onlookupchanged event not enabling save and cancel button, below code not working : might be column api names //show standard cancel & save button copyDraftValues.forEach((item) => { if (item.Id === updateItem.Id) { item[fieldName] = updateItem[fieldName]; draftValueChanged = true; } });

  3. Edit picklist field is also not enabling save and cancel, the above same issue

  4. First i edit lookup field then i tried to edit picklist field, but i can't select picklist values from dropdown, might be focus event issue. not sure if same issue for you

mickaelgudin commented 1 year ago

I'll have a look but for 1. both lookup and picklist custom datatype have to include the icon within the "custom cell" so we can't use "editable": true

Sarveshgithub commented 1 year ago

thanks @mickaelgudin changes you made solve the above issue

  1. is it possible to show the edit icon on an empty lookup field and update? image
mickaelgudin commented 1 year ago

@Sarveshgithub Actually the icon is displayed when the lookup is empty but only when the mouse is on the left or the the center of the cell,

it just needs CSS enhancement, could you check it ? It's the template of the datatableLookup component that needs fixing.

Sarveshgithub commented 1 year ago

hmm ok let me see