Tips_gui   >   Treelists   >   Treelist Columns
The treelist object supports displaying columns of data for each node in the treelist. If you are unsure of what that looks like, click the
button in the window to view a columns list style treelist.To set up a treelist with additional columns you need to do the following:
To display data in the treelist columns you have to set the $rowdata node property with a row variable that has the data you want to display in the correct order. Column 1 of the $rowdata will be displayed in column 2 of the treelist object columns, column 2 of the $rowdata in column 3 of the treelist object columns, etc.
There are two ways you can load the $rowdata into the treelist object:
$edittext(iColumnNumber)
Lets the user edit the text for a column in the currently selected line, when the tree is the current field. The node (column 1) can only be entered if its $enterable property is kTrue. You can control whether other columns can be entered using the evTreeListEditStarting event.
To stop columns from being editable add this to the $event method of the treelist object:
; Prevent text editing of columns.
On evTreeListEditStarting
Quit event handler (Discard event)
You only need to worry about the $edittext method if you want to initiate setting the user to edit a specific column in the treelist object. By deafult the user can click on any column in the treelist object and Omnis Studio will let the user edit the column value if you didn't discard the evTreeListEditStarting event.
$getcolumnalign()
Returns the alignment of the specified column. This only applies to trees with multiple columns.
; Get the column alignment for the 2nd column.
; kAlign will be: kCenterJst, kLeftJst, or kRightJst
Do irTree.$getcolumnalign(2) Returns kAlign
$rowdata
Each node in a treelist has a $rowdata property. You can set any row variable to the $rowdata property at any time. Once the $rowdata property has been set you can get the $rowdata from the node.
The data in the columns of the $rowdata property is displayed in the columns of a treelist object which has the $designcols property set to a value greater than zero.
; Set the row data for the specified node.
Do rNode.$rowdata.$assign(Row)
; or
Calculate rNode.$rowdata as Row
; Get the row data from the specified node.
Calculate Row as rNode.$rowdata
The following sample code demonstrates how you can get the value for a column in the row data which the user has just edited.
On evTreeListEditFinished
; Get the $rowdata for the current node.
Calculate Row as pNodeItem.$rowdata
; Get the value of the clicked column.
; The $rowdata column number is one less than the treelist column number.
Calculate Value as Row.[pColumnNumber-1]
$setcolumnalign(iColumnNumber,kAlign)
Sets the alignment of the specified column. You can specify kAlign as kLeftJst, kRightJst, or kCenterJst. The property $columnalignmode controls how $setcolumnalign affects the field. This only applies to trees with multiple columns.
; Set the column alignment for the 2nd column.
Do irTreeObj.$setcolumnalign(2,kCenterJst)