Xojo2024R3: WebListBox with datasource - query does not include unique row identifier problem

I have used WebListBox with DataSource approach in few WebPages already, these lists are showing records coming from Postgres database. All queries so far have included unique row identifier aka “pk”.
Today I am working on a page that is having quite complicated query due to the original design. The query starts with "SELECT DISTINCT " and there is no way for me to pull unique identifier for the each row - the row has few columns that store values coming from individual records in the same table.
I have noticed that without having “pk” specified in the query string I can still populate the WebListBox as expected. However, the “SelectionChanged” event and “Pressed” event is not firing.
If I include “pk” and populate it with something like “1” then the “SelectionChanged” event will fire only once. The “Pressed” event will fire each time but I can’t rely on the test pertaining to “SelectedRowIndex”.

I don’t think this is necessarily a bug but I can’t modify the query to include row identifier as the each row is the summerized output of 5 different rows from the same table.

Should I use “fake” number to populate the “pk” for each row? What will be the side effect if I do so?

In the WebDataSource.RowData event, you will have to return an array of WebListBoxRowData. Are you assigning the unique PrimaryKey property in those WebListBoxRowData instances?

Thanks for this suggestion, I was actually thinking about assigning unique line number right there in the RowData method as unique primary key property. I hope there would be no side effects to it.

Actually I have decided to use ROW_NUMBER() function as unique identifier column element in the query instead of modifying RowData method in the DataSource. The Pressed and SelectionChanged are firing now as expected.