Android Question B4XTable, hide one or more columns

vecino

Well-Known Member
Licensed User
Longtime User
B4XTable, Is it possible to hide one or more displayed columns?
I am testing like this with a 2 column table and I want to hide 1 column.

B4X:
Sub cargar As ResumableSub
    Dim cSq As String = $"select nombre, nombresintildes from tbObjetos where activo=1 and idbarco=? order by 1"$
    '
    tbSearch.Clear   
    tbSearch.AddColumn("Objeto",tbSearch.COLUMN_TYPE_TEXT)
    tbSearch.AddColumn("Hidden",tbSearch.COLUMN_TYPE_TEXT)
    
    Dim lll As List
    lll.Initialize
''    'Dim rs As ResultSet = ShCode.DBX.ExecQuery2(cSq,Array As String(ShCode.iBarcoPredeterminado))   
    Dim rs As ResultSet = ShCode.DBX.ExecQuery2(cSq,Array As String(1))
    Do While rs.NextRow
        Dim row(2) As Object
        row(0) = rs.GetString("nombre")
        row(1) = rs.GetString("nombresintildes")
        lll.Add(row)       
    Loop
    rs.Close
    tbSearch.SetData(lll)
    
    Dim lc As List = Array As String("Objeto")
    tbSearch.VisibleColumns = lc
        
    '
    Return Null   
End Sub

 
Solution

JohnJ

Member
Licensed User
Longtime User
Try setting the width to 0 or -1
 
Upvote 1
Solution

toby

Well-Known Member
Licensed User
Longtime User
You can also hide a column the following way:
B4X:
    Dim clmHidden As B4XTableColumn
    clmHidden=tblOrders.AddColumn("hidden column", tblOrders.COLUMN_TYPE_NUMBERS)
    tblOrders.VisibleColumns.RemoveAt(tblOrders.VisibleColumns.IndexOf(clmHidden)) 'hidden column
 
Upvote 1

TILogistic

Expert
Licensed User
Longtime User
Others:
Option 1:
B4X:
    B4XTable1.GetColumn("Company").Width = -1 'hidden column name
    'or
    B4XTable1.VisibleColumns.Get(2).As(B4XTableColumn).Width = -1 'hidden column index
Option 2:
B4X:
    B4XTable1.VisibleColumns.RemoveAt(B4XTable1.VisibleColumns.IndexOf(B4XTable1.GetColumn("Company"))) 'hidden column name
    'or  
    B4XTable1.VisibleColumns.RemoveAt(2) 'hidden column index
Option 3:
See:
 
Last edited:
Upvote 2

vecino

Well-Known Member
Licensed User
Longtime User

Just to try, I have tried the different options, and option 1 does not work for me.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Just to try, I have tried the different options, and option 1 does not work for me
It needs to be in the right place, after you define the columns like this: It works
B4X:
B4XTable1.AddColumn("Company", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.GetColumn("Company").Width = -1 'hidden column name
 
Upvote 2
Cookies are required to use this site. You must accept them to continue using the site. Learn more…