Pass parameter to docked view

I have a parameter that I need passed to a docked view. The parameter is passed down from the pageURL (xxxx/:ply) and I can see it in my primary view. However, I have configured the docked view to have an input parameter called “ply”, but it never reads the value the way the primary view does.

Any ideas?


image

1 Like

Using the Page Configuration GUI to specify Docked View Parameters does NOT allow for dynamic setting of Docked View Parameters at this time. The ply param for your Docked View will always get “value”, because that’s what you’ve set it to in the GUI.

If you want to dynamically set the Docked View parameter ply, I highly recommend using the system.perspective.openDock() method. As an alternative, you can use the Dock Action and dynamically set the parameters in there.

2 Likes

Is there a way to use either of these while still using the built-in handle to open the dock? We have the dock view hidden and it pops out when the user clicks on it. To me, it seems like the solutions you mentioned would be best suited for opening the dock with a new button?

image

Indeed they would be. The handles (like in your screenshot) do nothing but expand/collapse the Docked View; there is no way to attach any logic, properties, or params to them.

There are LOTS of different avenues for moving data around in Perspective, and no one way is best in all situations. I'll cover some of the methods for Docked Views.

Params:
Pros:

  • Allow for initial-state setup of the Docked View

Cons:

  • Only dynamically writable in Actions (Dock, Script)
  • Page Configuration GUI only allows for "default" value.

Session Properties:
Pros:

  • Available at any point of the Session lifecycle
  • Completely Dynamic

Cons:

  • Large quantities of session properties can become unwieldy
  • These retain values throughout the Session, so overwriting their value in one spot could result in undesirable consequences depending on use.

Message Handling:
Pros:

  • No hard-coded paths
  • Easily reused between Views

Cons:

  • Splits code into two places (broadcast code, logic code)
  • Listeners not in browser DOM don't hear sent messages
  • No registry, so logging is best method of troubleshooting

So I would try to determine how the Docked View is going to be used:

  1. If the Docked View is going to be expanded (Display == visible) by default, you would need to use Params or Session Properties, as message handling requires a manual action of sorts.
  2. If the Docked View is based off of PAGE parameters, you could conceivably use a View Startup script for the page's primary View to invoke the openDock() script; in this way you can open both the "Page" and Docked View with parameterized values on initialization (of course, this will happen any time the View starts up).
  3. If you can reasonably provide a button - and the Docked View isn't expected to be expanded by default - then message handling is probably the way to go.

TLDR;
Given your specific use-case (parameterized dock is collapsed, user expands Dock manually), I would recommend NOT using parameters for the Docked View. Session properties might be best: perhaps session.custom.ply? Then instead of binding against DockedViewName.params.ply, you would bind against session.custom.ply.

2 Likes

What about if you want to pass the parameters to a Dock because you are using a text field in that dock to see the header of the screen that you are. Is this possible?

The dock will be visible all the time so, calling the function opening dock will not help because you will end up having two docks open. Is there any way to do this functionality?

Also, knowing that in perspective can be many taps open at the same time, how could I configure the text field in the header to be unique in each screen?

I don't know what you're describing here. Could you post a picture or elaborate further on what you're trying to display?

From what I can glean by reading your full post it sounds like you're trying to display something like a page title. Pages don't have title, but you can display the name of the Page's primary View with self.page.primaryView.

At this point it isn't a parameter, it's a static binding against a property.


You can only ever have one Docked View expanded on one side of the screen. Opening (expanding) a Docked View would collapse any expanded DockedView for the side on which the Opening Docked View is attached.


Again, "header" is a very ambiguous term. To some people it means the browser tab title, to others it means "Top Edge Docked View".

It sounds like you're describing the browser tab. While there is no current way to change the text displayed in the browser tab, we do have an ope feature request to provide that ability.


I might be able to help more or explain more clearly if you can provide a more descriptive explanation of what you're trying to accomplish.

For those looking to use URL as parameters to both the main view and a docked view simultaneously, I did the following. Please let me know if there is a more elegant way. There would be the potential for multiple tabs being open, each with different parameters, so I didn’t go the Session route.

  • Build a landing page that will serve as the Primary View no matter what URL is used. I am using a blank screen for now.
  • In the Page Configuration, Create a page pointing to the Primary View with the URL having parameters specified “/page/:plant/:line”
  • Configure the docked view and set default parameters here if needed. Set a dockid and remember it for later. My docked view is a menu to navigate to different views.
  • Modify the Primary View to have view parameters, matching those in the URL: plant and line for example
  • Add an event script to the View bound to onStartup, to run “system.perspective.openDock(“sidebar”, params = {“dockedPlant”:self.params.plant,“dockedLine”:self.params.line})”
  • Modify the Docked View to have the View parameters matching those that were called by the script: dockedPlant and dockedLine for example

On loading the URL, the parameters pass from the URL to the Primary View. On the primary view load, it pushes the parameters to the dock with the openDock() function. In my case, the preference is to have the page load with the docked view shown to remind the user to select a view, so this method works for me. The next step for me to try is to add a script on the main landing page that will navigate to a more specific view depending on the passed parameters from the URL.

This is all a bit convoluted to pass parameters to both the Primary View and the Docked View, but it seems to work, except for an issue with stale parameters that I reported here

2 Likes

A post was split to a new topic: How to modify docked view handle width