regression ? is it a bug ? where is the headerPressed event ?
It doesn’t exist for a few reasons, the largest being a round trip to the server that’s not necessary.
What are you trying to do functionally? There may be options.
Hey there! So, I’ve got a 200,000-row dataset that I want to show only the first 50 rows to the user. The default sorting is by the newest row added, but sometimes I need the oldest one. How do I sort it in that direction? Also, I’m trying to do this all in just 5 lines of code, like I did in my DesktopListBox.headerPressed method. Is there a way to achieve this without adding any extra components to the interface? Few years back, HeaderPressed was there for weblistbox…
and i have an other issue, how to detect the user scrolled to the end of the list ?
You need to be using a DataSource for this much data.
When you change the column sort direction the framework will ask the DataSorce for the rows necessary.
We no longer need to add any code. The WebListbox handles the user interaction and sort direction. You return the rows from the DataSource.
Again, something improved by using a DataSource. We no longer need this bit of information because the WebListbox will handle “I need to show the next 50 rows now” for you.
Please investigate WebDataSource. The features it offers satisfies the needs you have mentioned here in a way that’s much better than the Web 1.0 way of doing things.
That’s the problem, my code uses less than 10 lines to do that in API1… Datasource, you need a bunch of methods and properties to make it work… I didn’t benchmark it, but I’m guessing my old fart method is faster (to code) AND to execute.
You’re probably wrong. DataSource is very fast. It’s designed for doing what you want in that the listbox requests just what it needs to display and gives the user the ability to scroll to anywhere in the list.
It does mean rethinking your query a little as an object that needs to be refreshed periodically however. I suggest that you create a class and apply the WebDataSource interface to it. Add a property to the class for the base query without the sorting ORDER BY or row filter LIMIT statements.
RowCount should only get recalculated on the first run or when the data has changed. It should return the total number of rows in the data set without filters.
RowData needs to run your query using the provided sort order and rows it asks for by adding a ORDER BY and LIMIT clause to your base query. Probably 20 at a time.
ColumnData should also only be recalculated on the first run and on data changes.
So what I mean here is you should put private properties on the class for storing the count and the column configuration and only recall those when they are zero or have zero elements, and make a refresh method that you call whenever the listbox data needs updating. You could even store a WeakRef to the listbox and have it also call the listbox’s refresh method after updating the query so you don’t have to remember.
It’s not hard, just a different way of thinking about it. It also makes it really easy to change the DataSource at runtime if you want to load different data depending on user choices.
Please give WebDataSource the opportunity it deserves. Here is a blog post that should help you getting started:
Then, if you are still not convinced, the next step would be creating a new Feature Request asking to add the WebListBox.HeaderPressed event
Well, you probably need to bite the bullet anyway. I had to convert old WebApp from Xojo2018 and ended using Data Source for all WebListBoxes, it took some time for me but in the end it works pretty well in the latest and greatest Xojo.