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

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
No partial wakelock.
*** : B4XPage_Foreground
*** mainpage: B4XPage_Created
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
*** B4XPage_Foreground ***
No partial wakelock.
*** mainpage: B4XPage_PermissionResult [mainpage]
Error occurred on line: 566 (B4XTable)
java.lang.ClassCastException: java.lang.String cannot be cast to com.conkex.stowship.b4xtable$_b4xtablecolumn
at com.conkex.stowship.b4xtable._calculatewidths(b4xtable.java:1339)
at com.conkex.stowship.b4xtable._refresh2(b4xtable.java:1023)
at com.conkex.stowship.b4xtable._refreshnow(b4xtable.java:3555)
at com.conkex.stowship.b4xtable$ResumableSub_SetData.resume(b4xtable.java:719)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 
Solution
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")...

JohnJ

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
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
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:

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
Top