Tag name: <amc:column>

The immediate children of a Table component must all be <amc:column> components. Each visible Column component creates a separate column in the Table.

Use "headerText" attribute on a Column to create the column header. The following example creates a two-column table with the column headers - "Firstname" and "Lastname":

<amc:table>
  <amc:column headerText="Firstname">
    ...
  </amc:column>
  <amc:column headerText="Lastname">
    ...
  </amc:column>
</amc:table>
          

The child components of each Column display the data for each row in that column. The Column does not create child components per row; instead, each child is repeatedly rendered (stamped) once per row. Because of this stamping behavior, only certain types of components are supported as children inside a Column.

As each row is stamped, the data for the current row ( see getRowData() on the Table) is copied into an EL reachable property. The name of this property is defined by the var property on the Table. Once the Table has completed rendering, this property is removed (or reverted back to its previous value). In the following example, the data for each row is placed under the EL property "row". Each Column displays the data for each row by getting further properties from the "row" property:

<amc:table var="row" value="#{myBean.employees}">
  <amc:column>
    <amc:outputText value="#{row.firstname}"/>
  </amc:column>
  <amc:column>
    <amc:outputText value="#{row.lastname}"/>
  </amc:column>
</amc:table>
          

In order to make a Column sortable, set the "sortable" property to true and set "sortProperty" to the name of the model that this column will sort.

<amc:table var="row" value="#{periodicTable.tableData}" id="t1">
   <amc:column headerText="Element Name" sortable="true" sortProperty="name" id="column1">
      <amc:outputText value="#{row.name}" id="ot1"/>
   </amc:column>
</amc:table>

Attributes

Name Type Supports EL? Description
align String Yes Specifies the alignment for this column. Valid values:
  • left (default): used when left-justified cells are needed irrespective of the LTR or RTL display.
  • center: used when center-justified cells are needed irrespective of the LTR or RTL display.
  • right: used when right-justified cells are needed irrespective of the LTR or RTL display.
filterable boolean Yes Specifies whether or not the column is filterable. The sortProperty attribute *must* be set on the column for it to be filterable. On Windows Mobile, a filterable column will have a filter field on the top of the column header. On BlackBerry smartphones, a contextual menu item is added to allow user to filter the data.
headerBackgroundColor String Yes Sets the color of a background of the column header to an RGB value (rgb(255,0,0)) or a hexadecimal number (#ff0000 or #f00). The default value is device-dependent.
headerFontFamily String Yes Defines a prioritized list of font family names and/or generic family names for the column header. The client will use the first value it recognizes. Valid values:
  • family-name: the name of a font-family, such as "times", "courier", "arial", and so on.
  • generic-family: the name of a generic-family, such as "serif", "sans-serif", "cursive", "fantasy", "monospace".
Note: Each value has to be separated with a comma, and a generic-family name should always be offered as the last alternative. Also, supported font type is limited by the mobile device operating system. Please verify if the specified headerFontFamily is supported on device or simulator.
headerFontSize int Yes Specifies the size of a font in points for the column header text.
headerFontStyle String Yes Specifies how the characters in text should be displayed for the column header. Valid values:
  • normal: defines normal characters.
  • bold: defines thick characters.
  • italic: defines slanted characters.
  • underline: defines underlined characters.
Two or more styles can be combined by providing a space between them. For example, the following creates text that is bold and underlined:

headerFontStyle="bold underline".
headerForegroundColor String Yes Specifies the color of the foreground of the column header text. The color value can be an RGB value (rgb(255,0,0)) or a hexadecimal number (#ff0000 or #f00). The default value is device-dependent.
headerText String Yes Specifies text to display in the header of the column.
id String No Specifies the identifier for the component. The identifier must follow the following rules:
  • Must not be a zero-length String.
  • First character must be an ASCII letter (A-Za-z) or an underscore ('_').
  • Subsequent characters must be an ASCII letter or digit (A-Za-z0-9), an underscore ('_'), or a dash ('-').
sortProperty String Yes Specifies the property that is displayed by this column. This is the property that the framework uses to sort and filter the Table's data.
sortable boolean Yes Specifies whether or not the column is sortable. On BlackBerry smartphones, this allows the end user to invoke sorting from the menu when the table is in either cell or component selection mode: a table-specific "Sort" menu item is automatically added to the displayed menu at the time when the Table component gains focus. On Windows Mobile devices, sorting can be invoked by clicking on the column header. The header of sortable columns contains arrows indicating which column is currently sorted and in which direction.

Note: In order for a column to be sortable, the sortProperty attribute must be set to "true" and the underlying model must support sorting by this column's property.
width int Yes Specifies the width of the column. Can be entered in pixels or as a percentage of the table width. The default width is 100px. There is no auto sizing for columns. Set the width attribute to ensure the column is wide enough to accommodate the width of the contents. A percentage value should be entered as a number followed by the "%" symbol. A number will be interpreted as a pixel value (as will a number followed by the text "px").