Conditionally Render Nested Table in Drawer, When there are Rows in the Table

CMCM
edited November 7, 2019 in Questions
I have a Table Component (T1) with a drawer that displays another table T2) of related records.
I am trying to only display the drawer's table (T2) when there are actually related records (so some drawers will show the table (T2), and others will not). 

I tried adding a rendering condition using the Table's (T2) Model Property of Has data rows, and also tried # of rows in model, but ther table (T2) still rendered.in the drawer. 

The Source Model Tooltip for the render conditions indicated that it will use the rows in context unless there are no rows in context in which case it uses the first row in the model, which explains why it isn't working using my logic, but I am unclear as to an alternative approach to achieving my objective.

Any suggestions would be much appreciated.

I am using API V2.

Comments

  • Luzie BaumgartLuzie Baumgart 🛠️ 
    edited November 7, 2019
    Hi Cookie Monster, thank you for the good question. We played around with render conditions in drawers on a V2 page, seems like the context can't be taken into account, hence the render condition doesn't provide the preferred result, like you said. There are probably different ways to achieve what you need, we found a quite quick way to make it work if you happen to use child relationship fields in the Table T2 in the drawer. For example your Table T1 shows a list of Accounts. The drawer contains Table T2 which shows related Opportunities (can be a different model). You could add a Child relationship field "Opportunities" to the Accounts model. You would also add a UI-only field to your Accounts model and set it up the following way:

    Name: NumberOfOppsChildRecords
    Display Type: Formula
    Formula Return Type: Number
    Formula: {{Opportunities.totalSize}}

    This UI-only field will show the number of related Opportunities for each Account. Now if you go to Table T2 in the drawer, you can create a render condition that checks if the field "NumberOfOppsChildRecords" (in the Accounts model) is greater than 0. This works, because checking the amount of child records doesn't need any context. Hope this is helpful for you :-)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!