cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Maintain Selected Rows through refresh

pbaierl
1-Visitor

Maintain Selected Rows through refresh

I currently call a service to populate a table, but to make sure that I am displaying the latest values I have to refresh the grid.  Once I do this the selected/highlighted row is lost.

Is there a way to maintain the selected row even after a refresh?

Thanks,

Paul

ACCEPTED SOLUTION

Accepted Solutions

Hi All,

The reason about it doesn't maintains the selected row it's becouse you don't have a Primary Key field on the DataShape, if you set a Primary Key field on the DataSet ( and of course it has a unique value ) the selected row will be maintained.

Carles.

View solution in original post

10 REPLIES 10
posipova
20-Turquoise
(To:pbaierl)

Off top of my had, you may try using an intermediate variable for storing "current selected row", and rebind upon the refresh?

Thanks Polina,

I am kind of already doing something like this using expressions.  I am able to keep the grid from moving around during a refresh.  I have also setup methods to retain the selected value so that the data I want remains.  The problem is that I have received feedback from some of our testers that it isn't acceptable to loose the highlighted row being displayed.

Is there a way to rebind/select the previous value?  I already keep track of what it is/was.  I just don't know hot to plug it back into my service or the grid to get the highlighting around the selected row back.

It was requested that I mimic the functionality of a list or drop down where a selected key is passed back into the widget to select an item.

ankigupta
12-Amethyst
(To:pbaierl)

Paul Baierl​, As per my understanding the selected row cannot be rebind back to the Grid. Grid just allows AutoSelect first Row option and it does not have SelctedItems option like in list widget.

You might have to create your own custom Grid widget for this feature. You can use the Grid widget as base for your Custom widget.

I hope it helps.

Thanks,

Ankit Gupta

Hi All,

The reason about it doesn't maintains the selected row it's becouse you don't have a Primary Key field on the DataShape, if you set a Primary Key field on the DataSet ( and of course it has a unique value ) the selected row will be maintained.

Carles.

I just tested and yes selected Row is maintained.

You don't trust me

I do trust you Carles Coll. I had tested it myself too so just added a comment in support of your comment.

I was just joking Double check it's always good.

Thanks Carles and Ankit!

This helps a lot on a number of issues I was having.  I completely forgot to set a primary key for some of my data shapes.  I went back selected a primary key and everything is working great now

Thanks again for the help.

dpellerin
4-Participant
(To:CarlesColl)

Hi!

Thanks for your help. It's true that setting a primary key to the datashape works in most cases. However, wrapping the SQL query service with a javascript services causes the selection to be lost if the SQL service returns more than one Infotable. Basically we're using Stored Procedure and we're wrapping the queries with a javascript service to handle errors.

Example of the SQL service with the JS service wrapper:

sqlServiceTest:

SELECT 1 AS 'id', 'value1' as 'value' UNION

SELECT 2, 'value2'

SELECT 1

I took a screenshot of the resulting tables to make it explicit. But basically this query would return the equivalent of 2 SELECT statement. The service then returns an Infotable that contains 2 Infotables automatically named Table0 and Table1. It's really easy to simulate and reproduce. The Table 0 would be the resulting table with the Datashape and the primary key set to the id field.

--------------

Example of the JS service that wraps the query, retrieves the Table 0 and returns it:

jsWrapperService

result = me.sqlServiceTest().Table0;

When doing this the selection is lost. That is even if you create all the required Datashapes with primary keys. When wrapping the SQL service that returns only one table with a JS service, the selection is not lost. So the problem really isn't because the SQL service is wrapped, but because 2 tables are returned.

Is there a workaround for the selection to be maintained?

Announcements


Top Tags