Listbox Very Slow to Load

For the last couple of years since going to Web 2.0 I have been experiencing this. Im looking to figure out how to fix it. The listbox in this video is very simple. It has two columns, the name of the color and the color. The list is a list of web safe colors. It shouldn’t be lagging this bad. Can anyone tell me how to get this listbox to load up correctly in this instance so that it behaves normally? Currently I am just adding row by row and using cell renderer to set the color. Thanks for any help. Here is a photo example.

The listbox loads about 10 colors and then just will not load the rest. When you scroll down, there is nothing. A few seconds later, something may pop up but then it disappears when you mouse over it.

Can you share a sample?
Maybe someone can comment looking at the code what to change.

There really isn’t a lot of code. Here is the open event for the listbox:

Me.ColumnWidths = "50%, 50%"
Me.HeaderAt(0) = "Color Name"
Me.HeaderAt(1) = "Color"

Me.SetHelpText(TextField_Help, "Click on a color to select it.")

Me.AddRow
Me.CellTextAt(Me.LastAddedRowIndex, 0) = SetStyle_BlankRow("Black")
Me.CellTextAt(Me.LastAddedRowIndex, 1) = SetStyle_CustomColorCell(App.WebColors.Black)
Me.RowTagAt(Me.LastAddedRowIndex) = App.WebColors.Black

Me.AddRow
Me.CellTextAt(Me.LastAddedRowIndex, 0) = SetStyle_BlankRow("Dark Slate Gray")
Me.CellTextAt(Me.LastAddedRowIndex, 1) = SetStyle_CustomColorCell(App.WebColors.DarkSlateGray)
Me.RowTagAt(Me.LastAddedRowIndex) = App.WebColors.DarkSlateGray

There are about 100 more of these addrow called to add another row. Here is the code for the method SetStyle_BlankRow

Public Function SetStyle_BlankRow(sString as String = "", iVerticalSpace as integer = 2, iHorizontalSpace as integer = 2) As WebListBoxStyleRenderer
  Var style As New WebStyle
  
  style.Value("background-color") = "#fff"
  style.Value("border-width") = ".5px"
  style.Value("border-color") = "#fff"
  style.Value("max-height") = "1px"
  style.Value("padding-left") = str(iHorizontalSpace) + "px"
  style.Value("padding-right") = Str(iHorizontalSpace) + "px"
  style.Value("padding-top") = Str(iVerticalSpace)+ "px"
  style.Value("padding-bottom") = "0px"
  
  Var cellrenderer As New WebListBoxStyleRenderer(style,sString)
  Return cellrenderer
End Function

Here is the method for SetStyle_CustomColorCell

Public Function SetStyle_CustomColorCell(Color1 as Color) As WebListBoxStyleRenderer
  Var style As New WebStyle
  Var sColor As String = "#" + color1.ToString.Right(6)
  'style.Value("background-color") = "#fff"
  style.Value("background-color") = sColor
  style.Value("border-width") = ".5px"
  style.Value("border-color") = "#fff"
  style.Value("max-height") = "1px"
  style.Value("padding-bottom") = "0px"
  
  Var cellrenderer As New WebListBoxStyleRenderer(style,"")
  Return cellrenderer
End Function

The colors are stored in a class for the app. It’s a pretty simple setup but the listbox does not load fully.

1 Like

Web 2 is far from stable now, why would you use it 2 years ago? :scream:

Im sure there is a hack somewere to make it work but the WebList sucks, dont use it.

The work around:

Create a container with a label and a rectangle, in there add 2 computed properties, “colorname” and “colorcolor”, on the set change the caption of the label and the background color of the rectangle. Add presed event of the label and raise a “colorselected” event

Create a second container, in its openning add dinamically many container1 (this could be really easy with control sets, but xojo decided to not included on web :roll_eyes: so) use EmbedWithin to add the container1 and set the colorname and colorcolor properties, use AddHandler to redirect the “colorselected” events of the container1s to a method in second container. Finally, raise another “colorselected” event in second container

In my case, contrary to Ivan, the webListBox object has worked very well for me. I have used it to display 1500 records.

It is much faster than previous versions.

I’ve noticed that what makes this object very slow is adding long content per column. It doesn’t matter if it’s text or image.

For example, I read from the database a field with a long description full of spaces. On the first try, don’t worry about cleaning everything. When trying to load a thousand records, it was slow.

Are any of you in the beta testers group? Listbox speed is important and one should test the latest betas, too, if possible…

Web2 still has many bugs for me to use it, I dont have a Current Pro license so I was kicked of the beta tester goup for that.

Beta testers is suposed to be exclusive for those with a current licence. Kind of a vicious circle, lack of testers → more bugs, more bugs → less licences, less licences → lack of testers…

2 Likes

I am working on the latest beta 58134.

today, you don’t need to have a pro licence anymore to be beta tester. you just ask xojo team to be part of the beta tester group.

I think you still need a current license, pro or not.

I notice that you are recreating your webstyles once per row, which is inefficient, you should create them once only and then store and reuse them. Not sure if that makes a bit difference though.

:+1:t2:

It should add some overhead code, so it adds some weight that could be avoided.

Should be discussed in the beta forum then: https://forum.xojo.com/t/weblistbox-loading-speed-in-2022r3/72583

You can still apply to the testers group, even without the Pro license.

See Welcoming more pre-release testers

2 Likes

It looks like there is a bug in the R3 beta happening when assigning a cell renderer. We’ll prepare a fix, sorry about that.

@Jeffery_Lemons we’ve been fixing one beta issue that was causing the WebListBox to take longer than usual to load. But if this is only affecting R3, can you please open an Issue to ensure it gets fixed urgently?

Thank you

Yes I will do that.

1 Like