Layout repeating elements horizontally in InfoPath 2003 SP1
In InfoPath, you can use repeating tables or repeating sections to display repeating elements. However, those two controls only allow elements to be arranged vertically. To illustrate, assuming the following data is bound to a repeating table:
<myGroup> <myRepeatingElement name="element1" value="value1"/> <myRepeatingElement name="element2" value="value2"/> <myRepeatingElement name="element3" value="value3"/> <myRepeatingElement name="…" value="…"/> </myGroup> |
The table will look like this:
Name | Value |
element1 | value1 |
element2 | value2 |
element3 | value3 |
… | … |
If you have a lot of those elements, the table will get very long and look ugly. So you'd want to layout those elements horizontally to better make use of the space available in the view. However, this is hard (if possible) to implement in InfoPath 2003 RTM without significant modification of your data source schema. With the data filtering functionality introduced in InfoPath 2003 SP1, it is a breeze to make the table look like this:
|
|
|
Here are the steps to achieve the results shown above:
- Insert a one-row layout table in the view. The column number should be the number of repeating columns you want to have. In the above example, it should be 3.
Note: For simplicity, I will only talk about repeating table below. You can do similar things with repeating section. - In the first cell of the layout table, insert a repeating table bound to desired data source.
- Double click on the repeating table to open the "Repeating Table Properties" dialog; click on the "Display" tab, then click the "Filter data…" button. On the dialog appeared, click on "Add" button to add a filter condition with type of "the expression" and value of "position() mod 3 = 1"(without quote, same below). You probably want to uncheck the "Show filter icon to indicate filtered item" option on the "Repeating Table Properties" dialog after the filter is added.
- Now copy the repeating table to the rest of the cells in the layout table inserted in step 1. Follow step 3 above to modify the filter expression according to the column index of the layout table.. For example, the repeating table in the second column should have a filter expression of "position() mod 3 = 2". The last column is special in that the expression there should be "position() mod 3 = 0".
- If necessary, choose one of the repeating table to allow "show insert button and hint text", and disable this option on other repeating tables.
That is it! Before you try this out, let me warn you one last thing: you will see a "control stores duplicate data" warning on each of those repeating tables. Not that it is going to cause any problems, as long as you configure the filters correctly.
[Update 07/27/2004] Office 2003 SP1 is released. Removing reference to InfoPath SP1 Preview.
Posted with Simple .Text Blog Editor