Hide and show tabs based on role in tab strip navigation

Hi,

I have created a project in which i’m using tab strip for navigation between windows.

Is it possible to hide and show the tabs based on some role? For example, i want to show the user management tab only to the administrator role? is it possible through scripting?

Please help me.

1 Like

yes, the tab strip component is driven by a dataset. what I usually do is I setup the tab component like I want it, then save the dataset to a client dataset tag. When I open the window, I setup a script that grabs that client dataset tag and then sets the hidden value on each row, each row being a tab in the dataset, based on if I want to show the tab or not. Then I push that new dataset to the tab strip component.

There are a bunch of ways you could do it, thats just the way I chose.

a simpler way may be setting up the tab strip how you want it then using the cell update binding to bind to a property for each of the tabs hidden property. then when you open the window have your script write to those properties.

1 Like

Thanks lot for your reply. It really helped me.

I tried to use cell update binding of tab strip->hidden property and tried to bind it various controls given below.

Ways tried:

  1. Creating a custom property in tab strip and bound it with the code given below:
    switch(
    {[System]Client/User/RolesString},
    “Administrator”,
    “No”,
    “Yes”)
    2)Created an expression tag and placed the code above.
  2. Tried with textbox with the code above
  3. Tried with button with the code above.

The problem for all the above ways is that, the value is set properly. However the tab strip is not refreshing. And Expression tag gave a REFERENCE_NOT_FOUND error. I was unable to figure it out.

So I have put 2 tab strips now and hiding and displaying them based on role. :slight_smile:

Thanks for your help.

I suspect it is something with your expression as I just tested using the cell update bound to a property and it worked fine using either a check box or a event script from a button.

Thanks for your reply.

In expression tag, i have placed the below expression and tried to bind the expression tag value in cell update binding->hidden property.

switch(
{[System]Client/User/RolesString},
“Administrator”,
“No”,
“Yes”)

and it gives a REFERENCE_NOT_FOUND error. What could be the problem in this code?

try this instead.

if(hasRole("Administrator"),0,1)

like this if the person logged in is an administrator it will return a 0 which allows the tab to be displayed, if not, then it will return a 1 which means hidden.

you shouldnt have to put this in a tag. just add a boolean custom property onto the tab strip and bind the hidden cell for the tab that you want to hide to that property, then put this in an expression on the property.

1 Like

Thank you diat150. It worked like a charm. Appreciate your timely help. :slight_smile: