Tips_tutorials   >   Studio104   >   Headed List Subwindow
Headed List Subwindow
The headed list object is one of my favorite list objects in Omnis Studio. In this section we will create a window which has a headed list object. The window will be
generic in design, allowing it to be used as a subwindow to present different data lists.
List Object vs. List Variable
One thing we need to clarify when talking about lists is the difference between a list object and a list variable.
- List Variable - A variable with the variable type set to List. The list variable has columns and rows and holds data. The list variable does not present the data to the runtime user. In a window class you normally use an instance variable for any lists you want to display in a list object. For clarity, I normally refer to a list variable as a data list.
- List Object - A window field object that is used to display the contents of a list variable to the user. Omnis Studio has numerous list objects: kCheckList, kComplexGrid, kDataGrid, kDroplist, kHeadedListBox, kStringGrid
Create Headed List Window
To create the headed list window class:
- F2 Browser > select Contacts library > click New Class > click Window.
- Name the window class, wHeadedList.
- Right-click on the window class in the F2 Browser and select Methods... in the context menu.
- Add the following instance variables in the Variables pane:
irDataList - Type - Item Reference - used to point the a list variable in the parent window
irListObj - Type Item Reference - points to the headed list object in this window
irParent - Type Item Reference - points to the parent window instance
- Add a $setParentRef method to the wHeadedList class methods.
- Add the parameter, pfrParent - Type - Field Reference to the $setParentRef method.
- Add the following code to the $setParentRef method.
Set reference irParent to pfrParent.$ref
Quit method kTrue
Later in this tutorial when the wHeadedList is instantiated as a subwindow, the $setParentRef method will be used by the parent window to register itself as the parent of the child subwindow.
- Add a $:ListObjRef property method to the wHeadedList class methods.
- Add the following code to the $:ListObjRef method.
Quit method irListObj
- Add a $setDataListRef property method to the wHeadedList class methods.
- Add the following code to the $setDataListRef method.
Set reference irDataList to pfDataList.$ref
- Press F3 to jump from the method editor to the window class editor of the wHeadedList window class.
- Press F3 again to open the Component Store palette window.
- Drag and drop the Headed List object from the Component Store to the wHeadedList window class.
- With the headed list field object selected press F6 to go to the field's properties.
- Set the headed field list properties as follows:
General tab
$name - HeadedListObj
$dataname - irDataList
$top - 20
$left - 20
Appearance tab
$designcolumns - 1
- Double-click the headed list object to go to the object's methods.
- Add a $construct method to the headed list object and enter the following code in the method:
Set reference irListObj to $cfield
Do $cfield.$edgefloat.$assign(kEFposnClient)
The $construct window class method code will run when the window is instantiated, just prior to it becoming visible in the display.
- Select the $event method of the headed list object and replace the existing code with the following code in the method:
If irParent.$event_HeadedListObj.$cando
Do irParent.$event_HeadedListObj
End If
All headed list events will be forwarded to the registered parent, provided that the parent window class has an $event_HeadedListObj method.