WebListBox + PagePanel = Not working?

I have a weblistbox.

I have a method that populates it from an SQLite database.

When the weblistbox is added to a webpage, the method works and the listbox is populated.

If I move the weblistbox to a PagePanel, the method runs (system.debuglog tells me what’s happening), BUT the listbox does not seem to update.

I’ve tries running UpdateBrowser on the weblistbox and the pagepanel, Nada.

I’ve tries running the method from the pagepanel shown event. Nothing.

I’m out of spiders. Inside joke.

Help? Anyone?

try
  Var rs As RowSet = userdb.SelectSQL(SQL)  
  lbUsers.RemoveAllRows
  lbUsers.AddRowAt(-1, "User ID", "Last Name", "First Name")
  if rs <> Nil Then
    for each row as DatabaseRow in rs
      lbUsers.AddRow(row.Column("username").StringValue, row.Column("last_names").StringValue, row.Column("first_names").StringValue)
      System.DebugLog("Add row: " + row.Column("username").StringValue + ", " + row.Column("last_names").StringValue + ", " + row.Column("first_names").StringValue)      
    Next
    rs.Close
  Else
    MessageBox("Query returned no records." + EndOfLine + EndOfLine + SQL)    
  End If
Catch error as DatabaseException
  MessageBox("Error: " + error.Message)
End try

lbUsers.UpdateBrowser
ppMain.UpdateBrowser

Hi Jason,

You didn’t specify, but I guess your using Xojo2020, web2.0.
I have the same issue within a container control.
I didn’t try the PagePanel.

You should at least copy the listbox to an empty page and see if it works…

I stopped trying using web2.0 for now. There are too many problems.

I know I’m not helping ;-(

Hi Olivier, thanks for the response.

Yip, Xojo2020, web 2.0.

You should at least copy the listbox to an empty page and see if it works…

If I move it to webpage (doesn’t have to be empty) it works just fine.

Thanks,

Jason

If you still have some faith you could create a feedback case …
I don’t create them anymore…

PROBLEM SOLVED
After a little playing around I found that if I run a

pagepanel.UpdateBrowser 

BEFORE I run the loop to add rows to the listbox, the listbox updates just fine.

Logically, I can see why this would work, but it does not seem to be intended behaviour of UpdateBrowser, but a side-effect of ‘bumping’ or ‘re initialising’ the listbox control. I’m guessing. For all I know it was all the spider sacrifices.

In any case, for now it works.

If anyone cares, and not too surprisingly, running UpdateBrowser on the listbox and the webpage failed to result in the listbox being updated.

UpdateBrowser on the PagePanel BEFORE adding rows to the listbox works every time.

UpdateBrowser on the PagePanel AFTER adding rows to the listbox does nothing - an empty listbox.

1 Like

So I found out this morning that the UpdateBrowser on it’s own doesn’t seem to have done the trick. I have to re-set the headers too.

Yeah, doesn’t make sense to me either. Feels really hacky.

This is what the code looks like:

ppmain.UpdateBrowser // ppmain is the PagePanel

lbUsers.RemoveAllRows

// If I remove this, then the listbox doesn't update or size properly.  Not sure which. 
// This does nothing if the pagepanel updatebrowser above isn't run first.  
lbUsers.HasHeader = True
lbUsers.HeaderAt(0) = "User ID"
lbUsers.HeaderAt(1) = "Last Name"
lbUsers.HeaderAt(2) = "First Name"


if rs <> Nil Then
  for each row as DatabaseRow in rs
    
    lbUsers.AddRow(row.Column("username").StringValue, row.Column("last_names").StringValue, row.Column("first_names").StringValue)
    System.DebugLog("Add row: " + row.Column("username").StringValue + ", " + row.Column("last_names").StringValue + ", " + row.Column("first_names").StringValue)
    
  Next
  rs.Close
Else
  
  MessageBox("Query returned no records." + EndOfLine + EndOfLine + SQL)
  
End If
Catch error as DatabaseException
MessageBox("Error: " + error.Message)
End try

Confirmed as a bug, if anyone else is affected by this.

feedback://showreport?report_id=62628

I’ve noticed that a listbox locked either horizontally or vertically fills as expected after the browser is resized even the slightest. Where ever that event propagates, it does something that kick things in gear.

Agreed, that’s what I observed too.

Interestingly, I just discovered that things work well when the listbox is placed on a TabPanel rather than PagePanel. That’ll work for me but probably not for everybody.

If you read my solution, I found a workaround that works. It’s hacky, but it works.