Group dynamic data within tables

Top Previous Topic Next Topic  Print this topic

Overview:

Sometimes, to make a point over some information or to make the information easier to understand, the data presented in tables must be grouped considering different criteria.

 

Solution:

This tutorial offers an example on how to group data from XML in tables.

 

In the example below the titles of CDs will be grouped by the country they were released in.

A sample data source named "cdcatalog.xml" has been already assigned from Samples\XML Samples\Template Samples to the document.

 

1. In Design View, firstly a row with two columns must be inserted by accessing the Table button located in the Table group under the Insert tab.

 

2. Then the user must right-click on the first cell and select Insert>Group Above... or access the Layout tab and select Insert Group>Group Above from the Groups group.

 

grouping1

 

3. A dialog box named Group By will be displayed.

 

4. To browse for the XPath used for grouping, the right arrow button corresponding to Group Context must be selected and the Edit Expression dialog will be displayed.

For this example, the Group Context will be "/ns:catalog/ns:cd" and the XPath will be "@country".

If the Merge content with first row option is checked, the content of the new row will be merged with the first row's content.

 

grouping2

 

Result:

 

grouping3

 

 

5. The "@country" field must be dragged and dropped from the Data Source dialog bar and placed in the first row's cell.

 

6. The second row must be converted to a repeating row by right-clicking on it from the Navigation bar and selecting the Convert to Repeating Row option.

 

7. In the Edit Expression dialog box that appears the user must browse for the "ns:cd" node.

 

grouping4

 

8. The "@title" field from the Data Source dialog bar must be dragged and dropped in the second cell of the second row.

 

grouping5

 

9. Finally, the user must right click on the cell that contains the "@country" field and select Span>Increase Row Span. The last row can also be deleted.

 

grouping6

 

Print Layout:

 

grouping7