Creates a traditional table of repeated items organized into rows. This is accomplished by creating a template row that includes all of the items that should appear in each row. This row is then linked to the XForms data model.
Each time a new row is added to the table, the template items are duplicated to create the new row. This occurs when the elements in the data model that are linked to those items are duplicated. This allows the table to expand to any size while ensuring that data for each row in the table is still maintained in the data model.
The template row is created within an xforms:repeat option. This option is used to group the items that create the template row, and also links the row to particular portion of the data model. The template items can be configured with any location relative to one another. This means that they need not appear in horizontal succession.
Rows are added or removed from a table using the xforms:insert and xforms:delete action respectively. For more information about actions, see XForms actions.
active, bgcolor, border, borderinfo, first, focused, itemlocation, itemnext, itemprevious, last, next, previous, printbgcolor, printvisible, rowpadding, visible, xformsenabled, xformsreadonly, xformsrequired, xformsvalid, xforms:repeat
Before creating a table, you should create the data model that the table will reflect. The data model should group the elements you want in the table by rows. For example, suppose you wanted to create a purchase order form. Your table might collect three pieces of information: what the user wants to purchase, how many units they want to purchase, and what the cost of that item is. You might create the following data model to store that information:
<po>
<order>
<row>
<product></product>
<quantity></quantity>
<lineTotal></lineTotal>
</row>
</order>
</po>
As you can see, the three data elements are contained by a <row> element. This will allow us to duplicate any number of rows.
For the actual table, we will use the following items to reflect the data model: a popup that lets the user select which product to purchase, a field that lets them enter a quantity for the product, and a label that displays the cost of the products. Furthermore, these items will be contained within an xforms:repeat option, we will link that option to the <row> element in the data model, as shown:
<table sid="itemsTable">
<xforms:repeat nodeset="order/row">
<popup sid="Product">
<xforms:select1 appearance="minimal" ref="product">
<xforms:label>Choose product</xforms:label>
<xforms:item>
<xforms:label>Widget</xforms:label>
<xforms:value>widget</xforms:value>
</xforms:item>
<xforms:item>
<xforms:label>Gadget</xforms:label>
<xforms:value>gadget</xforms:value>
</xforms:item>
</xforms:select1>
</popup>
<field sid="Qty">
<xforms:input ref="quantity">
<xforms:label></xforms:label>
</xforms:input>
</field>
<label sid="LineTotal">
<xforms:output ref="lineTotal"></xforms:output>
<value></value>
</label>
</xforms:repeat>
</table>
When the user adds rows to the table, the description of the table does not change. Instead, the data model expands to include the new data. For instance, if the user had entered two rows of data, your data model might look like this:
<po>
<order>
<row>
<product>widget</product>
<quantity>2</quantity>
<lineTotal>2.00</lineTotal>
</row>
<row>
<product>gadget</product>
<quantity>5</quantity>
<lineTotal>15.00</lineTotal>
</row>
</order>
</po>
Based on this data model, the Viewer will create two rows of the popup, field, and label items, with no changes to the markup for the table item. This occurs because the nodeset in the xforms:repeat binds to every <row> element in the <order>, duplicating the template items for each.
By default, only 1 pixel of space is inserted between rows. As such, we recommend that you position the items in your rows to add the desired amount of additional space to the top of each row. For example, you might set each item in a row to have a <y> value of 2, thereby adding 2 pixels of space to the top of the row.
However, computes within a row of a table can reference elements outside of the table.