WebListBox with DataSource: using row identifier

I will try to explain what I need so please have some patience and understanding.

I have been implementing WebListBox with DataSource using latest Xojo 2024R2.1. I have it working for reports (different reports producing different layouts using the same WebListBox with large datasets). Scrolling through the list and sorting works well most of the time though sometimes there is delay in getting data here and there.
Now trying to use the same approach with the other page of the web app that requires something extra. It is a fairly standard “drill in” interaction (a list of rows, user picks the row, does the selection from the context menu and drills in to see more details about the row).
I have few problems to solve.

  1. Assuming that the row identifier is present in the list as ID column and knowing that I can’t use CellTextAt method, is it possible to read the ID? If I can do this then I can pass it to the RowData method in the data source class, use the row query and get all the other values I need.
  2. How can I “hide” the row identifier (aka ID) from the WebListBox? (I don’t want to show column ID in other words).

The examples of WebListBox with DataSource does not give me any hints.

Currently I am relying on the selected row index and using to search array of WebListboxRowData returned by RowData method (the one that takes row count, row offset and sort column string), problem with that is that it is using query returning more data than I need and it requires proper order of the rows (I have to add row identifier to the sort regardless of what column is clicked) and I need to know the current offset.

Add RowTag by adding code to RowData method.
Then use RowTagAt.
Using the Example that comes with Xojo:

image

image


Edit: as rowtag is variant you don’t need to save as String. This was just a quick example.

1 Like

Alberto, thanks as usual. I think I am beginning to understand the whole concept a little better now. I see how to store PK or any combination of values (maybe as JSON) in the Tag. I see that the query in the RowData can return more than I need to expose. I also see that RowTagAt() method is functional when using DataSource (which is not the case with the CellTextAt() method)

I have now more questions regarding DataSource.

  • how long is the row set open?
  • do I need to close the row set explicitly at the end of the RowData method?
  • can I use different scope for rs? (rather than local var have property added to the class of type RowSet - if so, I could use it with some other custom methods?)
  • maybe instead of trying to change the scope of rs it would be better to use class property scope for the rows() array?

DataSource will execute every time is needed, so RowData too.
Each time is needed a RowSet is created, used and closed.
I don’t know why you want to change this. You may have a valid reason and you may find a way to do it. As I haven’t tried, I can’t help with that.

Well, all I want is to have a little better understanding of what I am doing. Anyway, thanks again for your help.