Clicking on Menu Tree item runs a script

#1

Hi
I want when I click on menu tree item instead of opening a page it run python script.
How should I do that?

0 Likes

#2

Hi @nader.chinichian, there is a component event called onItemClicked where you can run a script based on what was clicked. You’ll just need to filter the the items by label or something similar:

1 Like

#3

Thansks Joshua,
By the way so if I want to open my main view I have to use script or is there another way to do that? I mean I cant find any property for opening view on Menu Tree. There is only property for opening page.

0 Likes

#4

No prob! If your main view is setup via a Page Configuration path (shown below), you can assign that path to the target property of a menu item and that view will be shown. If you’re looking to do something semi custom like a popup or displaying a view that isn’t bound to a path, you’ll need to do that via script. In that case, just leave the target property blank for the menu item that you want to trigger this behavior, and use the script.

Perspectives Page Configuration

1 Like

#5

Hi
If I have some sub item menu and need to password protect them in the parent Item, How can I do this?
I can setup check password on Parent Item onItemClicked like you said and open page manually but how can I force it to go to sub menu?

0 Likes

#6

I think you might be better off using a script that would conditionally create the child items based on the password check. That way they just don’t exist until that check has been met. Alternatively, you could enable/disable menu items based on the password check, if that would work for your use case.

0 Likes

#7

Thanks. good idea.
for your second one, where the props for enable disable menu item?

0 Likes

#8

Each menu item has an enabled property that allows it to be actionable. If set to false, the menu item won’t open child items or navigate to a destination.

0 Likes