I have a WebListBox that is filled with the result of a user search using multiple search fields.
I have successfully used a DataSource, starting from the xojo example project, and I’m very satisfied with the performance!
Some things I don’t understand:
PrimaryKey - in the RowData method I can set a row.PrimaryKey value, but I can’t find the way to retrieve it, for example in a DoublePressed event.
I now use row.Tag to set the value and then me.RowTagAt(row) to retrieve it at DoublePressed, so what’s the use of PrimaryKey?
More, without setting PrimaryKey the DoublePressed event does not work!
Function UnsortedPrimaryKeys - here I retrieve and return the list of query result primary keys, but for what?
The more if I left the function empty breaks everything and nothing works…
The primary key is used by the framework to keep track of which rows are which, just like in the database. Remember:
the user can sort the rows by clicking on the headers
the browser only keeps enough rows in memory to show the user what they need
So when a user clicks a row, the thing that’s sent back is the primary key. That’s used to query the datasource again and figure out what the actual row number is based on the last time the data was retrieved.
The problem with SortedPrimaryKeys and UnsortedPrimaryKeys is that the query is for everything in the table without LIMIT and OFFSET, so if the table has hundreds of thousands of records it can take seconds to get the rowset, no?
yes, I imagine so, but I think that would be quite useless in terms of usability to show hundreds of thousands of rows in a listBox.
In my case the maximum could be around 10.000, and even so I think they are a lot…