B4J Question B4XTable - Hide columns.

LucaMs

Expert
Licensed User
Longtime User
Trying to hide the columns with "even header".
(Project attached)

10.png
5.png
 

Attachments

  • B4XTableColumnsTest.zip
    9.9 KB · Views: 126
Last edited:

William Lancee

Well-Known Member
Licensed User
Longtime User
The following hides the even columns, but I haven't figured out how to bring them back.

B4X:
    'SHOULD hide even header columns.
    For i = B4XTable1.VisibleColumns.Size - 1 To 0 Step - 2
        B4XTable1.VisibleColumns.RemoveAt(i)
        B4XTable1.Columns.Get(i).As(B4XTableColumn).Panel.Visible = False        '<== Add
    Next
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
OK got it.

B4X:
Private Sub Button1_Click
    ' Resets visible columns.
    Dim toggle As Boolean = B4XTable1.VisibleColumns.Size = 10
    B4XTable1.VisibleColumns.Clear
    For Each clm As B4XTableColumn In B4XTable1.Columns
        B4XTable1.VisibleColumns.Add(clm)
        clm.Panel.visible = True
    Next
    
    If toggle Then
        'SHOULD hide even header columns.
        For i = B4XTable1.VisibleColumns.Size - 1 To 0 Step - 2
            B4XTable1.VisibleColumns.RemoveAt(i)
            B4XTable1.Columns.Get(i).As(B4XTableColumn).Panel.Visible = False        '<== Add
        Next
    
        B4XTable1.Refresh
    End If
    lblVisibleColumns.Text = "Visible columns = " & B4XTable1.VisibleColumns.Size
End Sub
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Yes, the order was wrong. I put refresh in wrong place.

Is the original question a bug? Maybe you should post it there.

B4X:
Private Sub Button1_Click
    ' Resets visible columns
    Dim toggle As Boolean = B4XTable1.VisibleColumns.Size = 10
    B4XTable1.VisibleColumns.Clear
    For Each clm As B4XTableColumn In B4XTable1.Columns
        B4XTable1.VisibleColumns.Add(clm)
        clm.Panel.visible = True
    Next
    If toggle Then
        'SHOULD hide even header columns.
        For i = B4XTable1.VisibleColumns.Size - 1 To 0 Step - 2
            B4XTable1.VisibleColumns.RemoveAt(i)
            B4XTable1.Columns.Get(i).As(B4XTableColumn).Panel.Visible = False        '<== Add
        Next
    End If
    B4XTable1.Refresh                '<== Move to here
    lblVisibleColumns.Text = "Visible columns = " & B4XTable1.VisibleColumns.Size
End Sub
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The feature you are trying to implement isn't directly supported. VisibleColumns is not expected to change after SetData was called.
You will either need to manually modify the layout as @William Lancee did or clear the table and call SetData again.
I thought I would find your solution here, this morning; a bit like you were dressed in red, with a big belly and a long white beard šŸŽ… šŸ˜„

Ok, I understand your answer; however, I am not very clear about the usefulness of VisibleColumns: they are all the columns, since you cannot scroll the columns horizontally, right?


P.S. I woke up: I assume they correspond to the currently visible page. The purpose is to be able to manage the columns of the page currently displayed, for example to highlight some values.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Ok, I understand your answer; however, I am not very clear about the usefulness of VisibleColumns: they are all the columns, since you cannot scroll the columns horizontally, right?
The table acts as a user interface element and as a data store. The VisibleColumns list allows the developer to include data that will not be displayed, but will still be accessible programmatically.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Certainly this View is quite important, especially for B4J (but not only for this).

It deserves more work. I know, I should write which features should be added or improved, but I will do so "soon" with a "Wish" (I have "seen" them using it these days but have not written them down).

Thank you, Erel.
 
Upvote 0
Top