Webcontainers, is there a better/simpler way?

I’m sure this pertains to desktop containers as well, but…

In my web app, I have a webcontainer that acts as a listbox so to speak, I then “embedwithin” the “cells” which are also container controls. Sometimes I delete an entry or reshuffle, and wondering if there an easier way to remove all the “sub” containers when I re-order or delete some? So far I just parse through the controls and nil them out!

Thanks

I think that’s probably the best way. And in Web it’s pretty much essential to use “EmbedWithin” when embedding multiple container controls. Funky things happen with Web Containers already instantiated on the page. I have a main container on my page that I do instantiate in the IDE. It then has an array several smaller containers that act as custom controls. Those I all use EmbedWithin when the app runs.

Thanks Jon, much as I thought. Shame no simple DeleteAllEmbeds or similar. (OOh, I may have to extend it!).

[quote=91649:@Richard Gorbutt]I’m sure this pertains to desktop containers as well, but…
…easier way to remove all the “sub” containers when I re-order or delete some? So far I just parse through the controls and nil them out!
[/quote]

By “parse” do you mean something like this?

[code]Dim intControlCount as Integer = Window.ControlCount

For intCounter as Integer = intControlCount DownTo 0

If Window.Control( intCounter).Name = “MyControlToDelete” Then
Window.ControlAtIndex( intCounter ) = Nil
End If

Next[/code]

In my testing, Xojo doesn’t permit the Window.ControlAtIndex reference.

Thanks.

Containers dont get added to the Control List of a window or container. I created my own subclass of WebContainer that does this. You just need a property called ContainerList and then some methods to add/remove them. Setting them to nil wont be enough. You’ll want to remove them from this list as well.

So…after you call EmbedWithin, add the new class to an array.

When it comes time to clear the WebContainer rows, delete the array element representing the row. This will clear the WebContainer on the web page?

Is that a correct interpretation?

Russ, very similar.

dim icount As integer dim iContainers As Integer= ccGridList.ControlCount for icount = iContainers -1 DownTo 0 WebContainer(ccGridList.ControlAtIndex(icount)).Close next

Brock, Been thinking of that, I have the required data as an array of structures so I already have the master list so to speak but I prefer building my own grid as opposed to the WebListBox so I may add that as I extend the class. Thanks

Thanks so much! That syntax:

WebContainer(ccGridList.ControlAtIndex(icount)).Close

clears the WebContainer of rows successfully.

However, I’m experiencing an unexpected issue: I’m finding that after I tear down the WebContainer in such a way, the WebContainer’s ContentsScrolled event no longer fires when I re-populate the WebContainer. I am loading rows lazily so the scroll event is important to me.

I’ve tried calling WebContainer.ScrollTo( 0, 0 ) after the process, but it seems to have no effect. Are you experiencing this scroll event failure?

I’m using 2013r3.3 but testing in 2014r1.1 shows the same issue.

Russ, I’ll need to test that. My initial data hasn’t really filled the container yet. Let me try soon. I’ll let you know.

[quote=93454:@Russ Tyndall]Thanks so much! That syntax:

WebContainer(ccGridList.ControlAtIndex(icount)).Close

clears the WebContainer of rows successfully.

However, I’m experiencing an unexpected issue: I’m finding that after I tear down the WebContainer in such a way, the WebContainer’s ContentsScrolled event no longer fires when I re-populate the WebContainer. I am loading rows lazily so the scroll event is important to me.

I’ve tried calling WebContainer.ScrollTo( 0, 0 ) after the process, but it seems to have no effect. Are you experiencing this scroll event failure?

I’m using 2013r3.3 but testing in 2014r1.1 shows the same issue.[/quote]
If you manually scroll to the top using the mouse and then scroll down again, does it work?

No.

I would like to clarify that the “rebuilt” WebContainer scrolls ok, it’s just that it’s ContentsScrolled event does not fire.

I understand that. I was just wondering if scrolling to the top would reset the event.

Also, are you seeing this on a particular browser or does it happen everywhere?

Safari 6.x for sure … my memory is fuzzy on the other browsers.

I am away from my development machine. I’ll be happy to test Chrome and FF when I am back in place.

Np. If it’s safari, it’s likely the others will have this trouble too. File a feedback report with a simple example so we can look into it.

Russ, I can recreate this, clear the container and re-populate and contentsscrolled will not fire again! Right now, doesn’t hurt me, but I can see if I need to fill the view on demand it could. Thanks.

Richard, thanks for checking. I will file a feedback report.