WebListBox with WebDataSource

Looking at the example: WebListbox Datasource Example

If I add the event SelectionChanged to the ListBox1. I can get the SelectedRowIndex, but how do you relate that back to the rows datasource row or PrimaryKey value?

CellValueAt seems to be empty, and depending upon how the user resorted the list, SelectedRowIndex could be pointing to any data record.

What I do, since I have objects that represent database rows, I store the object as the row’s Tag. You should be able to store an object (or if you’re attached to a database a row id) in the row’s Tag and get them back with https://documentation.xojo.com/api/user_interface/web/weblistbox.html#weblistbox-rowtagat

Thinking about it now, it seems silly that we can’t get that WebListboxRowData object back out from the WebListbox. Someone should file a feature request :upside_down_face:

Here’s an example project I built from ARGen that shows how to use WebDataSource with objects: Chinook_Web.xojo_xml_project

You’ll need the Chinook database from here: https://github.com/lerocha/chinook-database/blob/master/ChinookDatabase/DataSources/Chinook_Sqlite.sqlite

1 Like