How to use event scripts for a component in another view

Hello, I have a tree component in a view in perspective. I want to use onItemClicked event script to control a component in another view. When I try to do it, I can’t browse the component properties that in other view. I am wondering how i can achieve my goal. Thanks

You have to send a message that the other view would listen to. Component and property access is constrained to the view in which you are executing.

hello, thanks for your reply, i am wokring with the message handler right, however, it only works fine within the same view, not over different views. (I checked the all three listen scopes). please let me know if there is may be something i did wrong. thanks!

Check the scope at which you “broadcast” the message, and check the scope of the component on which you configured the Message Handler script. It sounds like you might have the scope set at “view”, but your use case should probably use the “page” scope - though using “session” would probably not hurt you.

1 Like

Hello, it still not solves my issues. if they are in the same view, they are working fine even i only have page scope checked. However, if there are in different view, with all scenarios of the scopes, it still not works.

Here are my configuration, and I have try out all different scenarios for the listen scope
onitemclicked event on tree component:
image
messagehandler on xy chart:

Payload isn’t an optional argument, at least according to the documentation

Try passing an empty dictionary for this argument.

Hello thanks for your help. I tried it out, but exactly same issue, work within the same view, but not in different views.

Try: self.props.plots[0].trends[0].visible = False

In Jython, any non-empty string converts to boolean as True.

Ye, that still not work for the different views, I am thinking if there is anything else I need to configure other than the message handler, listen scope and the onclick event.

I just tried this with the following setup and it worked:

ViewA
Tree component
EmbeddedView component (path="ViewB)

ViewB
XY Chart

Instead of using the message handler script you used I simply logged that the message was heard.

If you still believe this is not working, I recommend placing your own logging within your scripts so that you can see where code might not be executing. Alternatively, perhaps there’s a disconnect in the terminology we’re using, or there could be a faulty assumption about your setup. Is your XY Chart on the same page as the Tree component? Some more insight into the setup of the View might help us determine where this is going wrong for you.

1 Like

Hello thank your for replying. It just work, I still don’t know why it was not. But thanks for all you guys help!