I am designing a LWC component that looks like below:

enter image description here

Here, I will use an Apex Wrapper to get the data for this table.

The wrapper stores the following info:

  1. Account Id [ex - Id of Account 1]
  2. Pattern Id [ ex - Id of Pattern 1]
  3. Pattern Name [ Name - Patter 1 ]
  4. Start Week [ ex July 10th ]

The above data is stored in a custom object that supports this UI. If no patterns is returned then I leave the cell blank as you see for Account 2 AND July 10. So that user can search the pattern using the lookup filter and set it here.

I am thinking to use a data table to implement this. However, what I am not sure about is how can I use a lookup component inside a data table? Is this even possible any better way to do it? PLease suggest if even should be using a datatable in this case or not.

1 Answer 1


You can use a datatable but in order to get a lookup inside a datatable like you've described, you will have to create a custom datatype.

Be sure to also check "Customize Data Type Layout and Styles"

The custom datatype will contain the lookup input in the manner you decide to implement (be it a custom lookup component, or a lightning-input of type "search", or a lightning-input-field inside a lightning-record-edit-form, etc...).

You will also have to implement a way to get the lookup value after the user enters it.

  • Can the columns in the data table change dynamically? It should be 5 weeks[shows the start date of each week). I wish to be able to move the dates to the next 5 weeks
    – SfdcBat
    Commented Jul 14, 2022 at 10:08
  • I believe you can add the track annotation to the column definition list variable and add or remove columns in the list dynamically and that track annotation will make the datatable refresh with the new columns. Since it sounds like you're changing the header too, so you would have to label the columns differently for each week.
    – Fernando F
    Commented Jul 14, 2022 at 17:23
  • Would you have any insight around this question - salesforce.stackexchange.com/questions/380775/…
    – SfdcBat
    Commented Jul 16, 2022 at 19:45

You must log in to answer this question.

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