Is there a way to keep the selected row in agreement with the property selectedRow?

I am running Ignition 8.1.42. I have a view with a Perspective table component tbl_Data.

Various buttons in this view update a database table and then I call a script get_data() to retrieve the database data and write to a session variable called ds_cache.

The table component tbl_Data has its data property binding set to the session variable ds_cache.

When a button on this view makes an update, like inserting data, I update the selectedRow property correctly but the view itself doesn't show the correct selectedRow. There seems to be a period where if the table is rendering new data that changing the selectedRow property doesn't work.

Is there a way to reliably keep what is shown visually and what the selectedRow says in alignment? I have tried using time.sleep() to delay the update to selectedRow but even that seems unreliable.

I would like to keep the ability to select rows manually as well but I was considering taking that away from the user and just styling the selected row as needed. I thought I would ask the community first however. Thanks for any input.

Hello,

I do something similar on my tables I learned somewhere in this forum:

Make a custom property binded to the table row

-Then in the label you want to show the selected table cell you do a expression binding similar to:
image

{..../ColumnContainer_1/TablaDNF_2.custom.technical03}[{...../TabContainer.custom.selectedRow-05},'CODE']

That comibines filtered data of the table with the choosern row.

image

then you get precisely the exact dat you expect as it get the selected row of the filterd data.

Cheers

I should have been more precise with the issue. Here is a better picture. The table shows visually that row 5 is selected but the property selectedRow is actually a 6.

I want the visuals on the table to match what the property actually is. This happens when I update the session variable feeding the table component and then update the selectedRow separately. So the user might be inserting a row in the middle, I update the data correctly, I update the variable selectedRow correctly, but the visuals don't match the properties anymore.

You should get the selectedRow from the same updated data that is feeding the table, instead of updating it separately. Otherwise, if a user inserts a row in the middle, the table visuals can become misaligned with the actual row properties.

The selected row should come from the underlying data, not from the table display.

Use an expression similar to:

{..../dataSource}[{...../selectedRow}, 'CODE']

Here, selectedRow represents the row selected in the table, while dataSource is the underlying source where the data is modified. This helps keep the selected row aligned with the actual data instead of relying only on the table’s visual state.

Basically, no.

Any component property that is driven from two directions is and will always be racy. (Just like PLC tags that get written by SCADA and by ladder.)

You need to set the selected row from the browser side, using javascript. IA doesn't offer a supported method to do this. Consider playing with @bmusson's Periscope module.

2 Likes

Aside: on my TODO list is a react-data-grid component.
No timeline.

3 Likes