It may be possible to use a method to add a column, but once I needed such and I didn't have enough time to search for it.
So, I had two possibilities:
1) reconstruct the table (ie initialize a new tableView and repopulating adding the new column). This was not my prefered one, since I had a very large table unfortunately, and it would take some time to reload,
and
2) insert new columns from the beginning and set them hidden. This way, once the user needed an extra column, all I did was to change the visible state of a hidden column.
This code is an example of how I did it:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private tblView As TableView
Private btnAddColumn As Button
Private lstOfColumns As List
Private lstOfVisibleState As List
Private numOfVisibleColumns As Int
Private maxNumOfCols As Int=5
Private defaultColWidth As Int=100
Private initTblWidth As Int
End Sub
Sub AppStart (Form1 As Form, Args() As String)
lstOfColumns.Initialize
lstOfVisibleState.Initialize
For i=0 To maxNumOfCols-1
Private visibility As Boolean
Private colText As String="Column " &(i+1)
If i<2 Then
visibility=True
numOfVisibleColumns=numOfVisibleColumns+1
initTblWidth=initTblWidth+defaultColWidth
End If
lstOfColumns.Add(colText)
lstOfVisibleState.Add(visibility)
Next
tblView.Initialize("")
tblView.SetColumns(lstOfColumns)
For i=0 To maxNumOfCols-1
tblView.SetColumnWidth(i,defaultColWidth)
tblView.SetColumnVisible(i,lstOfVisibleState.Get(i))
Next
btnAddColumn.Initialize("btnAddColumn")
btnAddColumn.Text="add column"
MainForm = Form1
MainForm.RootPane.AddNode(tblView,0,0,initTblWidth,300)
MainForm.RootPane.AddNode(btnAddColumn,0,310,100,50)
MainForm.Show
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub btnAddColumn_Click
Private numOfCols As Int=tblView.ColumnsCount
If numOfVisibleColumns<numOfCols Then
tblView.SetColumnVisible(numOfVisibleColumns,True)
tblView.SetColumnHeader(numOfVisibleColumns,"another column")
numOfVisibleColumns=numOfVisibleColumns+1
initTblWidth=initTblWidth+defaultColWidth
tblView.PrefWidth=initTblWidth
Else
fx.Msgbox(MainForm,"Reached max col num","Warning")
btnAddColumn.Enabled=False
End If
End Sub