B4J Question ABMinput does not fill column on abmtable

Rob White

Member
Licensed User
Hi All,
I have fought this most of the day it's now time to seek help.
I have a table on an ABMpage. Here is the code to build the table:-

Build table code:
Sub MakeTable() As ABMTable   
    
    Dim R As List
    R.Initialize
    Tbl.Initialize(page,"chemtbl",False,False,True,"mytheme")
    Tbl.SetHeaders(Array As String ("Chemical","Select","Rate","Units","Batch No."))
    Tbl.SetColumnWidths(Array As Int(200,1,15,15,50))        ' Auto column width = 0 see https://www.b4x.com/android/forum/threads/ambtable-autowidth-columns.120184/#post-751577
    Tbl.SetColumnVisible(Array As Boolean (True,True,True,True,True))
    Dim defUnit As String = Act.ChemUnits.GetCurrID
    For i = 0 To MaxChems-1
        Chem(i).InitializeWithSize(page,"chem"&i,ABM.INPUT_text,"",0,0,0,200,200,200,False,"")
        SelBut(i).InitializeFloating(page,"selbut"&i,"mdi-navigation-more-horiz","")
        Rate(i).InitializeWithSize(page,"rate"&i,ABM.INPUT_NUMBER,"",0,0,0,15,15,15,False,"")
        Unit(i).InitializeWithSize(page,"unit"&i,"",100,0,0,0,7,7,7,"")
        Batch(i).InitializeWithSize(page,"batch"&i,ABM.INPUT_TEXT,"",0,0,0,50,50,50,False,"")
        
        Chem(i).Narrow=False
        SelBut(i).UseFullCellWidth=False               
        Rate(i).NumberStep=1
        Act.ChemUnits.FillCombo(page,Unit(i),"ID")
        Unit(i).SetActiveItemId(defUnit)
        R.Clear
        R.Add(Chem(i))
        R.Add(SelBut(i))
        R.Add(Rate(i))
        R.Add(Unit(i))
        R.Add(Batch(i))
        Tbl.AddRow("R"&i,R)
    Next
    
    Return Tbl
End Sub

The table looks like this:

ChemTable.png




NOTE column 1 does not extend across to the button.

How do I make this happen?
What are the units for SetColumnWidths and .InitializeWithSize?
I have also tried other properties such as Chem(i).Narrow=False, this seems to do nothing.

Any help will be appreciated.
 

alwaysbusy

Expert
Licensed User
Longtime User
SetcolumnWiths is in pixels (0 = no fixed width, note that setting it to e.g. 1px will still be wider if the component inside the cell is bigger).
InitializeWithSize works like the grid system (so 12 columns with offsets and sizes from 1 to 12).

So for the ABMInput, you can either use:
B4X:
' this says, take 12 out of 12 = 100% of the column width
chem(i).InitializeWithSize(page,"chem"&i,ABM.INPUT_text,"",0,0,0,12,12,12,False,"")
' or just do not use InitializeWithSize but the normal Initialize, which automatically takes 100% of the column width
chem(i).Initialize(page,"chem"&i,ABM.INPUT_text,"",False,"")

Alwaysbusy
 
Last edited:
Upvote 0
Top