Xojo2024R3.1: WebListBox with DataSource - header click event not available, how to trap sort by column click?

The WebListBox does not have “click on column header” event. When user clicks on the column header the list is sorted in ascending or descending order - this is all good. However, this presents certain problem. I am trying to provide user with “multi row” update - meaning user can select multiple rows in the list, open dialog, change value of some attribute and save, the list is redrawn. Since this is the DataSource driven WebListBox I can control the ORDER BY clause by appending “id” column (this one is not exposed and provides unique row identifier) to ensure the same sort after DataReload. As Ricardo suggested I use mSelectedRows() array to store selected rows identifier, this is populated in SelectionChanged event of the WebListBox control.

The problem: after DataReload the selected rows are highlighted, when user decides to click on another column to sort and is using the selected rows to open WebDialog to change something on selected rows the mSelectedRows() array will store “stale” row identifiers - this is not good.

So, if column header click event is not available what shall I do?

Needless to say that the above scenario is unacceptable as it will lead to the update of wrong records in the database. As a workaround I can clear mSelectedRows() and force the user to re-select rows in the list, but in that case how do I de-select rows in the list?

Maybe this will work?

for each row as integer in mSelectedRows
  Listbox1.Selected(row) = False
next

Note: if mSelectedRows is an integer array

Yes, that is the only thing comes to mind, but the “rows” is definitely out of synch with the WebListBox.

In the meantime I have created the enhancement request:
https://tracker.xojo.com/xojoinc/xojo/-/issues/77792

Alberto, the real issue is that mSelectedRows() is out synch after sorting the list by clicking on the column header.
I could fix mSelectedRows() by looping through the list and checking Selected() attribute after the list is sorted, however, neither column header click event is available nor this would be an elegant solution. I believe that Xojo should really manage the selected rows state in the list after the column header click. I know that nothing is easy and I am not an expert on Xojo, but I need a solution, multi-select on WebListBox is such a basic feature that it absolutely must work correctly if serious WebApp is designed. I believe there is room for improvement but I need the solution “yesterday”.