[IGN-3549] Table selection is ignored during startup event

Hi,

We are running the nightly installed in the end of June (b2021062515). I have a project now where I want the top row to be selected as default when opening the view. I added a script to onStartup that loads selectedRow and selectedColoumn. Selection data is not updated until I click on a row. Is this the same bug?

self.props.selection.selectedRow = “0”
self.selection.selectedColumn = “Voyage”

That seems to be working for me in 8.1.7 which was before the nightly you supposedly have.

Please verify that your code is completing as expected:

# this line should supply a numeric value instead of a string
self.props.selection.selectedRow = 0
# This line should reference props
self.props.selection.selectedColumn = "Voyage"

on Event/onStartup on the table it self. I made labels linked to the used props and they return “null” until a row is selected.

I’m using a 8.1.8 nightly build and the properties are working as expected there. We did do some work with the Table recently and I suspect it may have fixed the issue as you’re seeing it. The repaired issue revolved around the selection.selectedRow and selection.data properties not updating if the underlying props.data property changed, but I could absolutely see how this might have been resolved by the changes. What version are you using currently?

Im at b2021062515

Oh! Is the Table driven by a binding? I’m betting you’re encountering an order of operations issue. I was able to replicate and I suspect it’s due to the fact that you’re setting a selection state for content which does not exist yet; the table is unable to reconcile the specified row/column combo because the binding has not resolved and so no rows or columns exist. Since the values supplied would be “invalid” the table ignores them.

I’m going to speak with a few people and see if there’s a better way to do this. I suspect some sort of onChange script coupled with a Boolean flag, but I’ll get back to you.

I moved this conversation to a separate thread because it is an unrelated issue and a separate internal ticket has been opened.

Yupp, its driven from a named query. I have been looking trough other events, but they will override a manual selection later on.

You could try using system.util.invokeAsynchronous to sleep one second before forcing the selection. Your user in unlikely to make a selection within that second, but there is still a chance the selection would appear to not be in place and then would just appear.

1 Like

invokeAsynchronous: Caution: Under no circumstances should you ever do anything in the function that is invoked asynchronously that interacts with the GUI. This means things like window navigation, setting and getting component properties, showing error/message popups, etc

I added a binding on my components display prop. If selectedRow equals null, I hide it, and show a label “Please select a voyage from the list” instead. Rather this than showing overlays for a second.

A default selection value would be nice.

That warning is for Vision, NOT Perspective. Note the broadly-scoped GUI term, instead of browser. I know it's a small distinction, but threads are handled differently in Vision than they are in Perspective, and so this is not a concern. If you're seeing overlays, then it's just a matter of the binding not having resolved. You could easily opt out of the overlay within the binding dialog.

I added a 1 sec sleep command before the script and it works fine

Try with a change script on the data property instead.
If you don't want the selection to be changed every time the table is updated, just add a custom property to hold a flag, and set it/check it when necessary.

edit: Actually I just tried and it doesn't work right off the bat.