The model

The table model provides the representation objects to be displayed in the associated table. It can be connected to a back-end application by means of an adapter. It refers to an attribute group IlpExtendedAttributeGroup to determine which attributes of the representation objects are to be displayed. Each time an attribute is added to or removed from this attribute group, a column is added to or removed from the table. (For more information on attributes, see Attribute API in the Business Objects and Data Sources documentation.)
Note
Each added column is arbitrarily placed at the end of the table, unless its position is defined as property index in the style sheets set to the table.
By default, the IlpTableView creates an instance of IlpTableListModel. This table model could be filled through an IlpDefaultListModel connected to a back end or could be used directly.
When the table is to be connected to a back-end application, a data source and a list adapter must be instantiated. Both the data source and the default list model must be connected to the adapter.

Managing attributes (columns)

Attributes contain the values of the representation objects, or of the business objects related to the representation objects, to be shown in the table. Attributes are displayed in the columns of the table.
Note
An attribute can also contain a computed value, that is, the result of a calculation, or refer to another attribute. See Introducing business objects and data sources.
The IlpAbstractTableModel class provides the following methods to manage these attributes:
  • setAttributeGroup sets the attribute group used by the table model to determine which attributes are to be shown. A call to this method does not empty the table model (which keeps its representation objects.)
    Note
    The representation objects and the table model do not necessarily use the same attribute group: the table model can provide computed attributes with values that are not in the representation objects.
    After a nonordered attribute group has been set to the table model, the attributes are alphabetically sorted in the table model. This constitutes the default order of the columns in the table. Each attribute added after the attribute group has been set to the table model is placed at the end of the table. This arbitrary order is modified when the property tableColumnOrder is defined for the accepted business class or when the property index is defined for the attribute represented in the column.
  • getAttributeGroup returns the attribute group used by the table model.
  • getColumns returns the attribute at the specified index.
  • getColumnCount returns the number of columns (attributes) contained in the table model.
  • getColumnNamereturns the name of the column, the index of which is given as parameter. The column name is the same as the attribute name.

Managing representation objects (rows)

The IlpTableListModel class, which extends IlpAbstractTableModel, provides the following methods to manage the representation objects in a table. The representation objects correspond to the rows in the table. These rows must be instances of an implementation of IlpTableRow.
To add or remove representation objects when you do not use an adapter and a data source, you must use the following IlpDefaultListModel methods:
  • add adds a representation object, o , to the table model ( o must be an IlpTableRow).
  • addAll adds a set of representation objects, c , to the table model ( c must contain only IlpTableRow instances).
  • remove removes the representation object whose index is given as parameter.
  • remove removes the specified representation object from the table model.
  • clear removes all the representation objects from the table model.