3.7 Tablix 1

The following is an example RDL definition of a Tablix element that is used in a very simple manner. The tablix acts as a container for a Rectangle; the rectangle contains the report layout. This layout provides similar functionality to the List element in schema versions prior to RDL 2008/01. The data is fetched from the Microsoft Adventure Works example database. An extract of the rendered XML is as follows.

Tablix example 1

Figure 17: Tablix example 1

The Tablix element has its Tablix.Name attribute set to "Tablix1". It has a single uncomplicated column, needing only the minimal TablixColumnHierarchy. The TablixRowHierarchy is almost as simple, but because the single tablix row is to be repeated for each row of data, the TablixMember is defined with a Group. There is no grouping, filtering, or sorting to be done on the Group, which defines it as a detail group.

   <Tablix Name="Tablix1">
     <TablixColumnHierarchy>
       <TablixMembers>
         <TablixMember />
       </TablixMembers>
     </TablixColumnHierarchy>
     <TablixRowHierarchy>
       <TablixMembers>
         <TablixMember>
           <Group Name="Details" />
         </TablixMember>
       </TablixMembers>
     </TablixRowHierarchy>

The single column is set to be 5.5 inches wide; therefore, the tablix is going to be 5.5 inches wide.

     <TablixBody>
       <TablixColumns>
         <TablixColumn>
           <Width>5.5in</Width>
         </TablixColumn>
       </TablixColumns>

The single row specifies a single TablixCell—because there is only a single column—and this has a Rectangle in it. The rectangle has various controls in it. For each row of data, the cell is repeated vertically, each being 0.42 inches high. The rendered height of the tablix depends on how many rows of data are in the DataSet.

       <TablixRows>
         <TablixRow>
           <Height>0.42in</Height>
           <TablixCells>
             <TablixCell>
               <CellContents>
                 <Rectangle Name="Rectangle1">
                   <ReportItems>
                     <Textbox Name="Address">
                       <CanGrow>true</CanGrow>
                       <KeepTogether>true</KeepTogether>
                       <Paragraphs>
                         <Paragraph>
                           <TextRuns>
                             <TextRun>

The value in the text box is a data row value, so it can change for each rendered row of the tablix.

                               <Value>=Fields!AddressLine1.Value</Value>
                             </TextRun>
                           </TextRuns>
                         </Paragraph>
                         <Paragraph>
                           <TextRuns>
                             <TextRun>
                               <Value>=Fields!City.Value</Value>
                             </TextRun>
                           </TextRuns>
                         </Paragraph>
                       </Paragraphs>
                       <Height>0.23958in</Height>
                       <Width>2.5625in</Width>
                     </Textbox>
                     <Textbox Name="StateProvince">
                       <CanGrow>true</CanGrow>
                       <KeepTogether>true</KeepTogether>
                       <Paragraphs>
                         <Paragraph>
                           <TextRuns>
                             <TextRun>
                               <Value>=Fields!StateProvince.Value</Value>
                             </TextRun>
                           </TextRuns>
                         </Paragraph>
                         <Paragraph>
                           <TextRuns>
                             <TextRun>
                               <Value>=Fields!CountryRegion.Value</Value>
                             </TextRun>
                           </TextRuns>
                         </Paragraph>
                         <Paragraph>
                           <TextRuns>
                             <TextRun>
                               <Value>=Fields!PostalCode.Value</Value>
                             </TextRun>
                           </TextRuns>
                         </Paragraph>
                       </Paragraphs>
                       <Left>3in</Left>
                       <Height>0.22in</Height>
                       <Width>2.6in</Width>
                       <ZIndex>1</ZIndex>
                     </Textbox>
                     <Line Name="Line1">
                       <Top>0.35in</Top>
                       <Left>0.15in</Left>
                       <Height>0in</Height>
                       <Width>5.2in</Width>
                       <ZIndex>2</ZIndex>
                       <Style>
                         <Border>
                           <Style>Solid</Style>
                         </Border>
                       </Style>
                     </Line>
                   </ReportItems>
                   <KeepTogether>true</KeepTogether>
                 </Rectangle>
               </CellContents>
             </TablixCell>
           </TablixCells>
         </TablixRow>
       </TablixRows>
     </TablixBody>

If there is more than one DataSet in the report, the Tablix.DataSetName element is required to be defined; otherwise it would default to the single DataSet available.

     <DataSetName>AddressDataSet</DataSetName>
   </Tablix>