Xojo2024R4: WebListBox with DataSource - RemoveAllRows method not allowed

The online help does not mention this but if you try to use RemoveAllRows with WebListbox using DataSource class you get this error:

WebListBox.RemoveAllRows is not allowed because you are using a datasource.

What I the equivalent code of this method then?

As a workaround I run query that returns nothing to clear the list but there should be easier way to do it, any suggestions?

:slight_smile:

Without a DataSource, WebListBox manages all the storage and querying of the rows. Using a DataSource gives you all the power, including having to wire a RemoveAllRows, if you need it.

Maybe you can add a RemoveAllRows method to your own WebDataSource class and perform something that makes sense in the context of your DataSource.

For example, if you are using a WebDataSource to display a log of recent events in your application, RemoveAllRows could be setting the timestamp of the current time in an internal property. You could then use that property in RowCount and RowData for querying the events database, and fetching just the events that happened since that timestamp.

1 Like

OK, so effectively for the MyWebDataSource.RemoveAllRows I need to run query like

SELECT * FROM my_table WHERE 0 = 1

This should then clear the list, correct?

Returning 0 in RowCount and an empty array on RowData will clear the list. You don’t really need to query the database.

OK, thanks.