Table |
Table represents a set of data elements that are organized into a grid. This control is derived from the AJAX Toolkit library - Grid. For details about the behavior and functionality of the control, refer Grid.
The business objects are displayed as the rows in the table. The Table control is autoextent enabled, that is, the default height of the table is set as auto.
Table controls are always bound to a model from which they fetch data. You can bind a Table control to a model by setting its model property in the property sheet or connect using the APIs. This enables the table to represent each business object of the model in a row. Thus, adding a row to the Table is equivalent to adding a business object in the model.
When you add a control to the Table, it appears as a column in the table. You can access the control in each row using <control ID>
[<row index number>]. For example, use input1[5] to refer to an input control in the fifth row.
The controls that can be inserted in a Table control are Check, Image, Input, List, Output, Password, Select, and Textarea.
Enumeration and Multiple-values Support in Tables
There is a necessity to display a part of one business object as a table. This applies to those business object which have aggregated objects or enumerated business attributes.
In this case, a Table should have a reference property, an XPath expression that would return zero or more of these entities from the business object. The XPath returns node set, and each node from this set is represented as a row.
A single business object can also hold multiple entries within it.
<Employees> <EmployeeID>1</EmployeeID> <Orders> <Order> <OrderID>10270</OrderID> <CustomerID>WARTH</CustomerID> </Order> <Order> <OrderID>10270</OrderID> <CustomerID>WARTH</CustomerID> </Order> <Order> <OrderID>10270</OrderID> <CustomerID>WARTH</CustomerID> </Order> </Orders> </Employees>
In the above example, Employees is the main business object and it has multiple values called Orders . A groupbox may be used to display a single Employees object. The groupbox can have a table to represent the multiple orders associated with an employee. The table can display such enumerated data in a list or select box.
For tables with enumeration support, the Reference/xql property must point to a node under the business object which has multiple nodes that the user wants to display in the table. In this case, the model will be attached to the parent of the table and the table actually displays only a part of the business object in the model.
In the above example, the main control that is a groupbox would hold a unique Employees object in the groupbox and the table only represents the orders which are part of the employee object. Such tables will not have a view attached to it and its view property will point to the view of its parent and the businessObject property will point to the business object of the parent. They will not support the pagination bar, Refresh button, and the Show All buttons. Such tables will have a property called currentContext , which will point to the node under the business object to which the table is attached.
The create() method, which is equivalent to the default Insert button, when called on such tables will return the current node set created. The node that is a part of the parent business object is created and not the entire new business object. Similarly, the Insert button creates a current node. The Delete button removes the current node set and, when saved, an update will be called on the model attached to the parent, as the table represents only a part of the data. The following methods are supported by tables that support enumeration:
- getRows()
- getCheckedRows()
- checkRow()
- getIndex()
- setIndex()
Note:
If there are more number of records to be displayed, use Xgrid instead of table for high-performance.
Properties, Events, and Methods of the Control
The properties, events, and methods associated with the Table control define its behavior. You can set them either through the control's property sheet or programmatically using the APIs. For details, see Grid.
The following XForms-related properties, events, and methods are available for the control:
Table 1. List of Properties
Design-time property |
Runtime property |
Description |
---|---|---|
Sets the string that identifies the control on an XForm. If not specified, a unique ID is automatically generated. |
||
Sets the ID of the data model from which the data (specified using the Reference property) is displayed in the control. If model is not specified, it is inherited from the parent control's model. |
||
Sets the location or expression for the XPath that contains the data (value) displayed in the control. The XPath refers to the child node or descendants of the immediate parent control's reference. |
||
Parent | Specifies the data binding from the parent. The selected parent is used as the starting point for data references. | |
Sets or retrieves the class name applied on the control. |
||
Minimum Number of Rows to Display |
minRows |
Determines a default value for the height of the table. When autoextent behavior is enabled, the height of the table changes depending upon the value of this property. The number of rows that will be displayed during runtime is independent of the number of records and is always greater than or equal to this value. |
Resizable |
Select to enable the resizing of control at run time. Note:
|
|
Denotes whether checkboxes will display on the Table control or not. When checked, a non-resizable column of checkboxes appears on the Table control with a Check All checkbox using which you can select or clear all rows in the table. By default, the Check All checkbox is selected. |
||
Save Grid State |
Specifies if modifications made to the Table control (column size and placement) will be retained when the XForm is visited again at runtime.The value is set as false (unchecked) by default. For details, see Grid. |
|
Display Context Menu |
displayContextMenu |
Sets or retrieves the boolean value that denotes whether a context menu will appear when you right-click the header of the Table control. The value is set as true (checked) by default. For details, see Grid. |
Toggle Columns |
toggleColumns |
Sets or retrieves the boolean value that denotes whether the columns of the Table control can be toggled (to show and hide them) at run time. When selected, it is possible to hide columns across the Table control. The same can also be done using the context menu of the header of the Table control. For details, see Grid. |
Auto Insert |
Adds a new, empty row to the table when you enter valid data in the last row of the table. This is applicable for a table associated with a transactional data model only. |
|
Task Part |
Check to create a task part for the control. Selecting the check box, displays the Task Part pane. |
|
Fixed Header |
|
Indicates whether the table header always remains visible at the top of the table even when a user scrolls down the table
|
Sortable |
sortable |
Check to enable sorting of columns in the control. You can use it as tableid.sortByColumn(columnIndex, sortOrder). Possible values for the sortOrder parameter are:
|
Adjust LastColumn |
fixedWidth |
Indicates whether the last column can be adjusted when the width of the table is changed.
|
Denotes whether the control will contain a Control bar or not. When selected, a Control bar appears on top of the control. By default, it is unchecked. |
||
Denotes whether the control will contain a Pagination bar or not. When selected, a Pagination bar appears on top of the control. By default, it is unchecked. |
||
Sets the properties of the application to be opened when a row in the Table control is clicked. All necessary properties of the application (such as Dialog URL and ID) are set here. |
||
Retrieves the root node of the XML data associated with the control; the location of the data is specified by the Reference property. |
||
Retrieves the immediate parent of the data that the control represents. This data is the child node of the business object. |
||
contextmenu |
Sets a handle to the Context Menu object that is displayed by right-clicking the header of the table control. The displayContextMenu property can be used in combination with this property to show or hide the context menu. For more information, see Grid. |
|
Retrieves an object through which the Control bar and Pagination bar button objects can be accessed at runtime. |
||
saveState |
Sets or retrieves the boolean value that indicates whether the Table control's current state (such as position and size of columns) is saved for subsequent visits to the XForm. For details, see Grid. |
|
shadeClasses |
Sets or retrieves the string value that is applied to achieve shading of alternate rows in a Table control. Each specified class must be separated by entering a space, for example "light lightmedium". Once set, the redraw() method of the Table control needs to be invoked to use it. |
|
Retrieves the view object of the data model bound to the control. |
Table 2. List of Events
Event |
Description |
---|---|
This event is activated when the columns in the grid are hidden or shown. |
|
This event is activated when you select a row. |
|
This event is activated when you select a check box corresponding to a row. |
|
onsetdefault |
This event is activated when you select Set Grid Default from the context menu of the table header to set the table to the default state. |
This event is activated when you click on a row. |
Table 3. List of Methods
Method |
Description |
---|---|
This method registers the control to receive notifications for an event. |
|
This method selects or deselects a row by selecting and clearing the check box corresponding to the row. |
|
This method is available for data-bound controls only. It creates an instance of the business object for the control. |
|
This method disables the control on which it is invoked. |
|
This method enables the control on which it is invoked. |
|
This method displays the Find dialog box. This is equivalent to clicking in the navigation bar. |
|
This method retrieves data or business object. |
|
This method returns the index of the selected row. It returns the value '-1', if no data is associated with the row. |
|
This method returns an array of all rows of the Table control that have business objects associated with them. |
|
This method returns an array of all rows of the Table control that are selected by checking the corresponding check boxes. |
|
This method returns the value displayed in the control. |
|
This method hides controls and all associated child controls. |
|
This method retrieves the value that denotes whether the control is enabled or not. |
|
This method marks a row or a collection of rows for deletion. |
|
This method is available for all controls bound to a model. This method refreshes the control with data from the business object that is passed as a parameter. If no parameter is passed, the business object of the model's activeTuple node is used and the control is refreshed. |
|
This method reverts the latest unsaved changes, and binds the control to the latest business object. |
|
This method is available only for data-bound controls. It removes the instances marked for deletion. |
|
This method unregisters the control to cease receiving notifications for its events. |
|
This method highlights and selects a row of the Table control. |
|
This method makes the control and its child controls visible. |