Conditional Rendering of Tabs within Drawer Not Working

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I am trying to conditionally render tabs within a drawer based on whether or not there are rows in the model within that context.  I cant seem to get this to work. Any ideas?
Photo of DannyS

DannyS

  • 294 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of mB Roman Melnik

mB Roman Melnik

  • 2,802 Points 2k badge 2x thumb
Interesting problem. Because while most components within a Drawer or Popup will have defineable Context, the Tab Set won't.


I think this is possible using the Rendering Condition Type of 'Snippet returns true'

In the image below, the Parent object on the drawer is Accounts, and the child is Contacts. If there are existing Contact rows in context, I want to render the first tab. But if there are no Contacts on that Account, I only want to render the 2nd tab.

Is that, generally speaking, what you're trying to achieve?


As for the snippet itself, this thread should be of use: https://community.skuid.com/skuid/topics/how-can-i-obtain-the-context-row-in-a-javascript-snippet
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,040 Points 10k badge 2x thumb
If you're hoping to hide the whole tabset for cases in which the drawer doesn't have any related rows inside, you might try putting the tabset inside a wrapper, and conditionally rendering the wrapper only when the relevant model has rows. 
Photo of mB Roman Melnik

mB Roman Melnik

  • 2,802 Points 2k badge 2x thumb
Agreed. That would be a much simpler solution - and you can do that declaratively with no js. But I *think* DannyS is trying to conditionally render individual tabs within a tab set based on Model Context.

Hmm.. Could this be done using the Action Framework 'Before Load Actions' on the drawer? Maybe to update a set of Ui only checkbox fields that correspond to each individual tab?

Just throwing ideas around. Not sure how viable this is though.
Photo of DannyS

DannyS

  • 294 Points 250 badge 2x thumb
Yes, unfortunately it would be much easier if I wanted to just render the whole tabset. I will first look to see if I can leverage the action framework using the example above. If not I will go the JS route.  Thanks!