B4J Question ABMaterial ABMTabs help

walterf25

Expert
Licensed User
Longtime User
Hi all, i have the need to create or insert an additional tab during runtime, i have the following code, but for some reason it doesn't create the additional tab for me, can anyone maybe shed some light as to what i must be doing wrong?

ABMTabs:
            Dim tabs As ABMTabs = page.Component("tabs")
            Log("tabs component found: " & tabs.GetActive) ''just to make sure I found the tabs component
            Dim cont2 As ABMContainer = BuildTabContainer("tab3", "")
            cont2.AddRows(1,True, "").AddCells12(1,"")
            cont2.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
            tabs.AddTab(tablename.Text, tablename.Text & " Inventory", cont2,3,3,3,12,12,12,True,True, "mdi-action-work", "")
            
            page.Cell(2,1).Refresh
            tabs.Refresh

BuildContainer code:
Sub BuildTabContainer(id As String, Text As String) As ABMContainer
    Dim Tabc As ABMContainer
    Tabc.Initialize(page, id,"tabpagewhite")
    
    Tabc.AddRows(3,True, "").AddCells12(1,"")
    Tabc.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    
    Dim lbl As ABMLabel
    lbl.Initialize(page, id & "lbl", Text, ABM.SIZE_H5, True, "")
    Tabc.Cell(1,1).AddComponent(lbl)
    Return Tabc
End Sub

Thanks all,
Walter
 

walterf25

Expert
Licensed User
Longtime User
I think you run AddRows and BuildGrid twice (once in BuildTabContainer, resulting in cont2) and then again on the same cont2
I also tried commenting out those two lines, but i still can't see the third tab being added, i'm not sure if there's anything else I should be doing?

Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I think you run AddRows and BuildGrid twice (once in BuildTabContainer, resulting in cont2) and then again on the same cont2
Just want to make sure i'm explaining this correct, I create the first two tabs inside the BuildPage Sub, the first two tabs work just fine. What i'm actually trying to do is insert more tabs as the user requires, there's a modalsheet that pops up asking the user if they want to create a database table, then the information regarding the new database table is collected, i.e. table name, field names, field types etc.. Once the information regarding the database table is entered, the table is created and a new tab needs to be added so that the new database table can be loaded on the new tab. For some reason the new tab doesn't show up, and i don't see any errors that can give me a hint as to whether the new tab was actually created or not.

Any thoughts?

Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I missed that part. Not sure if this is possible. You may have to remove the whole tab component and rebuild it from scratch.
I was afraid of that, didn't really want to have to do that as there's a lot of data being loaded inside a table on the second tab ?

Will give it a try and see if it doesn't slow things down too much.

Walter
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Just checked the source code for the tabs in Materialize CSS and they haven't forseen anything to add tabs later. I think it has to do with the complexity of the sliding color line that they do not allow it. Also, the jQuery plugin they use has the same restriction. I first thought to somehow create 'hidden' tabs, but I immidiately noticed that this line was miscalculated so not an option. Must be the reason why they initialize the tabs component in the document Ready event, which does only run once. Trying to remove the component and adding all new tabs will be your only option I'm afraid ?
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Just checked the source code for the tabs in Materialize CSS and they haven't forseen anything to add tabs later. I think it has to do with the complexity of the sliding color line that they do not allow it. Also, the jQuery plugin they use has the same restriction. I first thought to somehow create 'hidden' tabs, but I immidiately noticed that this line was miscalculated so not an option. Must be the reason why they initialize the tabs component in the document Ready event, which does only run once. Trying to remove the component and adding all new tabs will be your only option I'm afraid ?
I was afraid of that, no worries, already trying to remove it and re-create it like you suggested, however i'm running into some other issues now, I must be tired, will continue tomorrow morning with a fresh set of eyes.

Thanks for checking.
Walter
 
Upvote 0
Top