Xojo2024R2: WebListBox.CellValueAt is not allowed because you are using a datasource

This is using Postgres database to populate WebListBox with DataSource. The code does the data export from the list.
Xojo is reporting error:
“WebListBox.CellValueAt is not allowed because you are using a datasource.”

The offending code:

s = s + ResultsList.CellTextAt(j, i).StringValue.ReplaceAll("'","`") + Chr(34) + EndOfLine.Unix  

Assuming that it is not a bug, how should I modify this code to make it work?

Note: Xojo says “CellValueAt” for the code using “CellTextAt”

Not a bug, check the example that comes with Xojo, that may help, for example this code from the example:

label1.Text = String.FromArray(TableDataSource(Me.DataSource).RowData(row), ", ")

With the API2 changes originally it was CellValueAt and renamed to CellTextAt, I think still works if you type CellValueAt, looks like the internal message has not been updated.

Alberto, could you please let me know which example you were quoting? Thanks.

image

methods are there to be used not to raise excuses …

This may help too:
https://documentation.xojo.com/api/user_interface/web/weblistbox.html#weblistbox-datasource
https://documentation.xojo.com/api/web/webdatasource.html
https://documentation.xojo.com/api/web/weblistboxrowdata.html

WebDataSource could add a few methods to make it simpler for use to get values.

Please add a feature request asking Xojo to understand what we want and give us the information without changing our code and not showing a warning that we need to change our code because we are using datasource.

I guess this should be possible.

Alberto, thanks for the links, I looked at them before posting, I couldn’t get too much out of them.
I have also looked at the example you quoted, obviously it doesn’t have export method.
My problem was that I have set RowData method as Private so it was not recognized initially, I had to make it Public of course, finally I got this to work though:

vValue = String.FromArray(QueryPageDataSource1(ResultsList.DataSource).RowData(j),", ")
If i = ResultsList.ColumnCount - 1 Then
  s = s + vValue + Chr(34) + EndOfLine.Unix  
  //s = s + ResultsList.CellTextAt(j, i).StringValue.ReplaceAll("'","`") + Chr(34) + EndOfLine.Unix  
Else
  s = s + vValue + quote 
  //s = s + ResultsList.CellTextAt(j, i).StringValue.ReplaceAll("'","`") + quote  
End If

So, now that this part is done it looks so obvious to me, thanks.

2 Likes

Done:
https://tracker.xojo.com/xojoinc/xojo/-/issues/76838

I think Markus is referring to your original code should work with or without datasource. As in, is responsibility of Xojo to shield the user of more work if what they want is obvious (the contents of a clicked cell).

2 Likes