Hi everyone,
I'm currently working with the GridAdvanced widget in a ThingWorx Mashup and I’ve encountered a behavior that I’d like to improve.
The grid is populated correctly, and I’ve set the DefaultSelectedRow property to 1, so when the mashup loads, the first entry is automatically selected — which works as expected.
However, here's the issue:
When I select a different row, make some changes, and then refresh the grid (e.g., by re-binding the data), the grid resets to the default selection (row 1) instead of staying on the row I had selected and updated.
This causes a disruption in the workflow, especially when users want to immediately view the changes they made to a specific entry without having to re-select it again manually.
Is there a recommended way or workaround to preserve the selected row in the GridAdvanced widget after a refresh, so that the grid does not jump back to the default selection?
Any advice, workaround, or guidance would be greatly appreciated!
Thanks in advance,
Solved! Go to Solution.
Hi,
I’ve found a reliable way to handle it.
When you select an entry in the mashup and then update it (e.g., by saving changes that trigger a refresh via a GetProperties
data service), the grid will by default jump back to the row defined in DefaultSelectedRow. That’s why you lose your current selection.
The workaround is to use the Id property of the GridAdvanced:
Go to the Id field of the widget properties.
Set this to the parameter/field from your DataShape that is always unique (e.g., the primary key or unique identifier column for example in my case i have written entryDate which is always unique for my entries).
By writing the fieldName in to the GridAdvanced Id which is your unique DataShape field, the widget can always re-select the correct entry after a refresh. This way:
The selected row stays highlighted.
The updated values are shown immediately.
The user doesn’t have to manually re-select the entry again.
This approach ensures that the grid maintains the current selection even across automatic refreshes.
Hope this helps!
Hi @MA8731174,
One way to achieve preserving the selected row in grid after refresh would be using Session parameter to temporarily store the user selected row before refresh and populate this value to Grid's SelectedRow after refresh.
Check out Help Center for more information on Session Parameters
Flow is sth like below:
Refresh Button Click
↓
Trigger JS service say "RecordSelectedRows" to store the current selected row(s) in session parameter with Resources["CurrentSessionInfo"].SetGlobalSessionInfoTableValue({name: <SessionParaName> ,value: <SelectedRows_InputFromGrid>})
↓
Upon "RecordSelectedRows" ServiceInvokeCompleted, trigger service say "GetGridData" to refresh the grid data
↓
Upon "GetGridData" ServiceInvokeCompleted, trigger another JS service say "GetPreviousSelectedRows" to get the session parameter value using Resources["CurrentSessionInfo"].GetGlobalSessionValues().<SessionParaName>
↓
Bind the Returned Data of "GetPreviousSelectedRows" to SelectedRows of the Grid
Best,
Hi @MA8731174,
It appears that a response to this post answers your question. For the benefit of other Community Members who may have the same question, it would be great if you could designate it as the Accepted Solution.
In the event that this response did not answer your question, please post your current status so that we can continue to support.
Thanks for using the PTC Community!
Regards,
Hi,
I’ve found a reliable way to handle it.
When you select an entry in the mashup and then update it (e.g., by saving changes that trigger a refresh via a GetProperties
data service), the grid will by default jump back to the row defined in DefaultSelectedRow. That’s why you lose your current selection.
The workaround is to use the Id property of the GridAdvanced:
Go to the Id field of the widget properties.
Set this to the parameter/field from your DataShape that is always unique (e.g., the primary key or unique identifier column for example in my case i have written entryDate which is always unique for my entries).
By writing the fieldName in to the GridAdvanced Id which is your unique DataShape field, the widget can always re-select the correct entry after a refresh. This way:
The selected row stays highlighted.
The updated values are shown immediately.
The user doesn’t have to manually re-select the entry again.
This approach ensures that the grid maintains the current selection even across automatic refreshes.
Hope this helps!