Hide tab based on count

  • 1
  • Question
  • Updated 3 years ago
  • Answered
If I have 2 tabs with the same count is there a method to hide one of the tabs.

If Member has a count of two which equals the Location count of two, then I want to hide the Location tab. How do I render this?
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,776 Points 4k badge 2x thumb
Set the render conditions of the location tab to be the following:

Source Type: Model Property
Source Model: Member (or whatever is driving your Member count of 2)
Model Property: # of rows in Model
Operator: =
Content: Single specified value:
Value: {{$Model.Location.data.length}}
(Edited)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Yup that's right. Condition values do not process merge syntax.  Sorry.  I don't think there is an easy way to do what Bill is asking.  Some Javascript needed....
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
I believe that you could create a model with model conditions requiring the counts to be the same. Then if that model has rows, you don't need to render the tab.
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,776 Points 4k badge 2x thumb
Ah of course, didn't think about merge syntax in the conditions. My understanding is tabs are not constantly re-rendered, so if you did have a model like Matt suggests, you would have to have a snippet to re-render the tab after the "data rows model" is updated. Is that correct?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Craig,

I believe you would just want a model action on your "data rows model" to run a one-line javascript snippet:

skuid.$C('MyTabsetId').render();
Photo of Craig Rosenbaum

Craig Rosenbaum

  • 4,776 Points 4k badge 2x thumb
Yep, that's what I was talking about!