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
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
Note that even columns are displayed last (no longer in order).
However, with some effort you can find a workaround (maybe) but I think there is a bug in the B4XTable, because the attached project should work (unless I have misunderstood how it works).
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
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.
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.
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.
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).