Conditionally render drawer component based on context conditions

  • 2
  • Question
  • Updated 4 years ago
  • Answered
This question is somewhat related to this post Conditionally render drawer component based on context conditions.


I have a drawer action defined on a table.  Within the drawer is a tabset that contains a tab that contains several tables.  The use case is the conditionally render each of the tables based on the context row.

Of course, table column rendering would work great here :).

Any thoughts?

Best,
Irvin
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb

Posted 4 years ago

  • 2
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Irvin,  in my testing this is an automatic feature of tables.  In a drawer, when you conditionally render components  based on fields that are in the model that drives the table,  the row context will be automatically taken into account.  

Example:  In drawer of accounts, only show a particular component when account is of type "foo".
- When you open drawer of account  A - of type "foo"  the component will show. 
- When you open drawer of account B - of type "bar" the component will NOT show. 

Am I missing some complexity in your use case? 
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
I have a table of line items. Within one of the drawer tabs, I have several tables of another sobject. So two models. I want to conditionally render these tables based on context LineItem.Field == 'some value'. Does this make sense?

According to the help text it will use the first row, not the context row.

Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Rob,

So I went back and double-checked my models and changed all the table rendering rules to use QuoteLineItems so that the line item in context would be used.

Yes, it worked. Awesome. Thanks.

Regards,
Irvin
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Thanks for pointing out the need to change our help text!