Perspective Dashboard - Set widget z-index via scripting

Is anyone aware of a way to set the z-index of a widget in the Perspective Dashboard? Perhaps a property of the widget JSON? I sometimes need to do this when widgets are moved around after adding and they slip behind another. I would like to also give our users the ability to move widgets up/down in z-order.

Thanks

1 Like

Any luck with this one?

Yes, actually. Thanks for reminding me to post.

The z-index of a widget is solely determined by the order in the widgets array on the Dashboard object. So you can reorder those using scripting for the desired z-index.

Hope this helps!

2 Likes

Nice! Thanks for the update. Is it possible to know what the currently / last resized or moved widget is? Like some sort of event handler that fires? I can't find anything in the dashboards component that would do that.

I was hoping to do something where the last edited widget gets moved to the top of the array order to keep it above everything in Z-index.

We never tried that, just allowed users to move widgets up/down in z-index manually.

My first thought is possibly your widgets property should be changing on edit. You could keep track of the previous state and try to figure out yourself which widget changed, move it to the end of the list, and then most importantly make sure that script doesn't refire. It could recurse if you're not careful.

You could also watch for changes to the params of your widget and send your own message that the dashboard component has a handler for, that will reorder that widget. Might be hard to tell which param changes are from startup vs edit, but you could probably track that as well with a custom prop.

Just some random thoughts, hope that helps.

1 Like

I've only played with the Dashboard component a little, but would it make sense to analyse the widget sizes or positions and auto-Z them based on that. e.g. Smaller on top of larger or splayed out from left to right / top to bottom.