B4J Question [ABMaterial] Collapsable Container usage.... my many issues...

Cableguy

Expert
Licensed User
Longtime User
Hi Guys,

So... back again at it!!!

"cont2" is a collapsable container created in the "ConnectPage" sub, using this code;
B4X:
    Dim cont3 As ABMContainer
    cont3.InitializeCollapsable(page, "cont3", "", "", "", False)
    cont3.CollapsableHeading.AddRows(1,False,"").AddCellsOS(4,0,0,0,3,3,3,"")
    cont3.CollapsableHeading.BuildGrid ' IMPORTANT!
'    cont3.CollapsableHeading.OpenContent
'    cont3.CollapsableBody.OpenContent
    
    cont2.Cell(1,2).AddComponent(cont3)
    cont3.CollapsableHeading.Row(1).Margintop = "75px"
    cont3.CollapsableHeading.Row(1).marginBottom = "0"
As you can see it is already inside another container, but this is besides the point.

Inside "cont3", each cell holds a button.
My objective is/was to create a different "CollapsibleBody" grid, depending on which button was clicked...

B4X:
Sub btn1_Clicked(Target As String)
    LogError(Target)
    Dim FloatingCont1 As ABMContainer = page.FloatingContainer("floatingcont1")
    Dim Cont2 As ABMContainer = FloatingCont1.Component("cont2")
    Dim collbody As ABMContainer = Cont2.Component("cont3")
    collbody.CollapsableBody.ClearGrid
    collbody.CollapsableBody.AddRows(1,True,"").AddCellsOS(3,0,0,0,4,4,4,"")
    collbody.CollapsableBody.BuildGrid ' IMPORTANT!
'    collbody.CollapsableHeading.OpenContent
    collbody.CollapsableBody.OpenContent
    
    Dim btn1 As ABMButton
    btn1.InitializeFlat(page, "btn1", "", "", "{B}Activitées{/B}", "topbar")
    btn1.UseFullCellWidth = True
    collbody.CollapsableBody.Cell(1,1).AddComponent(btn1)
End Sub
This is giving me 3 different issues:
1st - First button click does not expand the collapsable body. Second button click does, whiwh then brings me to my second issue:
2nd - Each time the collapsableBody expands, a new row is added... which seems logic... maybe?
3rd - I try to eliminate the 2nd issue by placing a "clearGrid" just before I create it again, but it doesnt work and the Dody ends up empty...

SO.... for the first one... I guess I'm missing an itinial state, but I can't see how to set it...
and for the second and third.... should I just go with a different solution, using one collapsable container for each button?
 

alwaysbusy

Expert
Licensed User
Longtime User
I'm not at my PC right now so I'm trying to do this from my phone. I would do this. At the end of the btn1_click try to add collbody.refresh (at that point in your code, all is 'defined' on the server side, nothing pushed to the browser yet). Do the collaspableBody.Addrows (1 row, 1 cell) when you create the cont3. I would then create three containers, one for each button. In btn1_clicked, collbody.collapseablebody.row(1).removeallcomponents (can't recall the correct method name out of my head) to remove the previous 'button' container (if any) and add the new 'button' container to the cell(1,1). Then do a refresh. I can try more tomorrow morning.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
At the end of the btn1_click try to add collbody.refresh (at that point in your code, all is 'defined' on the server side, nothing pushed to the browser yet).
This seems to have taken care of the "ClearGrid... BuilGrid" portion....
Now I just need to figure out how to expand on the first button click
 
Last edited:
Upvote 0
Top