InfoPath Basics: Repeating control basics in InfoPath

This article explains the basics of repeating tables and repeating sections in InfoPath.

ADVERTISEMENTS

Introduction to repeating controls

A repeating control in InfoPath is a control to which you can dynamically (via the InfoPath user interface or through code) add rows or sections, or from which you can dynamically remove rows or sections. A section is a control that can contain other controls.

There are 3 types of repeating controls in InfoPath:

  1. Repeating table controls
  2. Repeating section controls
  3. Horizontal repeating table controls (only available in non-browser-compatible InfoPath form templates)

The name Repeating Table is a little bit misleading. Repeating Rows would have been a better name for a Repeating Table, because the rows in the table are repeated, not the table itself.

How to add a repeating table to an InfoPath form template

To add a repeating table to an InfoPath form template:

  1. In InfoPath on the InfoPath form template, place the cursor where you want to add a repeating table.
  2. On the Insert menu, click Repeating Table.
  3. On the Insert Repeating Table dialog box, enter a number for the Number of columns you want, and click OK.

How to add a repeating section to an InfoPath form template

To add a repeating section to an InfoPath form template:

  1. In InfoPath on the InfoPath form template, place the cursor where you want to add a repeating table.
  2. On the Insert menu, click More Controls.
  3. On the Controls task pane, click Repeating Section.

    Repeating Section control on the Controls task pane in InfoPath
    Figure 1. Repeating Section control on the Controls task pane in InfoPath.

  4. Click inside the repeating section you just added to the InfoPath form template (a hatched border appears around the repeating section), and then click and add controls from the Controls task pane to the repeating section.
    Adding controls to a repeating section in InfoPath
    Figure 2. Adding controls to a repeating section in InfoPath.

Data structure of a repeating node

Structurally, there is no difference between a repeating table and a repeating section.

While the 3 types of repeating controls may look different on an InfoPath form, their data source structure is the same. This is important to remember especially when you are writing code to for example programmatically add a row to a repeating table.

The data structure of a repeating node consists of:

  1. A non-repeating group node
  2. A repeating group node
  3. One or more fields

Basic data structure for a repeating node (table or section) in InfoPath
Figure 3. Basic data structure for a repeating node (table or section) in InfoPath.

If you create a repeating table with the data structure displayed in Figure 3 and then preview the InfoPath form and add 3 rows to the repeating table, the structure of the repeating table would be as displayed in Figure 4, where repeating-group-node1, repeating-group-node2, and repeating-group-node3 represent the rows of the repeating table with each repeating group node having its own field1, field2, and field3 fields. The non-repeating group node would be the table itself, which functions as a container for the rows.

The structure of a repeating table's rows in InfoPath
Figure 4. The structure of a repeating table's rows in InfoPath.

The output of an InfoPath form is XML, so the XML for the repeating table shown in Figure 4, would look something like:

<non-repeating-group-node>
  <repeating-group-node>
    <field1 />
    <field2 />
    <field3 />
  </repeating-group-node>
  <repeating-group-node>
    <field1 />
    <field2 />
    <field3 />
  </repeating-group-node>
  <repeating-group-node>
    <field1 />
    <field2 />
    <field3 />
  </repeating-group-node>
</non-repeating-group-node>

Note: XML namespaces have been omitted for clarity.

The XML for a repeating section with 3 fields in each section would look similar to the XML displayed in Figure 4.

 
 Subscribe for updates via RSS or Email

Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent of S.Y.M. Wong-A-Ton. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author, S.Y.M. Wong-A-Ton.

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners
InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013
InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners
InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010
InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers
InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services


Related InfoPath Articles:

ADVERTISEMENTS

InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services