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.
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
As I’d outlined you can use ActiveRecord objects as RowTags. I do not know of anyone filing a ticket to request access to the WebListboxRowData object. You should do so if you’d like to take a different approach, but quickly looking it seems like what I described still works.
The SelectedRowIndex should be converted in the background to match the order of the last request. After the first request, it’ll be the default sort order. If the user sorts the rows, your data source is sent the sort order, so you re-pull the data.
Since you need to return the primary keys in the order that you pulled them, just keep that array around and query it.