Grids

31 views
Skip to first unread message

Daniel Patfield

unread,
Apr 1, 2014, 5:03:34 PM4/1/14
to dot-net-...@googlegroups.com
I am using an xsl file that is transforming an xml file and the final result winds up in pdf format due to report writer.

The fields are easy to reference, but how do I create a table (grid?) from the data?
In other words, what properties do I establish:

DataContext = ?

Can I just  name a section from my xml file?

Daniel Patfield

unread,
Apr 1, 2014, 5:05:47 PM4/1/14
to dot-net-...@googlegroups.com
Here is the xml below.  How do I get the <ApprovedBeneficiaries> section to display in grid format?

- <data>
- <Record>
- <PersonalInfo id="PersonalInfo" type="form">
  <CurrentDate type="date">4/1/2014</CurrentDate>
  <NameHeader type="string">Jamess Lim</NameHeader>
  <NameSalutation type="string">Jamess Lim</NameSalutation>
  <Address type="string" />
  <CityStateZip type="string">,</CityStateZip>
  </PersonalInfo>
- <SpousalInfo id="SpousalInfo" type="form">
  <SpouseText type="string">We hope that Mrs Jane Smith likes this report too.</SpouseText>
  </SpousalInfo>
- <ApprovedBeneficiaries id="ApprovedBeneficiaries" type="table">
- <Row>
  <FirstName type="string">Jane</FirstName>
  <LastName type="string">Smith</LastName>
  <SocialSecurityNumber type="string">002-30-2309</SocialSecurityNumber>
  <Description type="string">Spouse</Description>
  <DateOfBirth type="date">6/1/1960</DateOfBirth>
  </Row>
- <Row>
  <FirstName type="string">John</FirstName>
  <LastName type="string">Smith</LastName>
  <SocialSecurityNumber type="string">023-42-3432</SocialSecurityNumber>
  <Description type="string">Beneficiary</Description>
  <DateOfBirth type="date">1/1/1960</DateOfBirth>
  </Row>
- <Row>
  <FirstName type="string">Jan</FirstName>
  <LastName type="string">Lim</LastName>
  <SocialSecurityNumber type="string">234-34-3333</SocialSecurityNumber>
  <Description type="string">Beneficiary</Description>
  <DateOfBirth type="date">1/1/1980</DateOfBirth>
  </Row>
  </ApprovedBeneficiaries>

siberix

unread,
Apr 1, 2014, 5:40:24 PM4/1/14
to dot-net-...@googlegroups.com
Hi Daniel,

You need to transform you xsl table section into the following Siberix Report XML:

...

<Grid Borders="Black">
<Column Width="20%" />
<Column Width="20%" />
<Column Width="60%" />

<Header Repeat="True">
<Row>
<Cell Borders="Black" Paddings="5">
<Text Style="Style1">First Name</Text>
</Cell>
<Cell Borders="Black" Paddings="5">
<Text Style="Style1">Last Name</Text>
</Cell>
<Cell Borders="Black" Paddings="5">
<Text Style="Style1">SSN</Text>
</Cell>
</Row>
</Header>

<Row>
<Cell Borders="Black" Paddings="5">
<Text Style="Style2">Jane</Text>
</Cell>
<Cell Borders="Black" Paddings="5">
<Text Style="Style2">Smith</Text>
</Cell>
<Cell Borders="Black" Paddings="5">
<Text Style="Style2">002-30-2309</Text>
</Cell>
</Row>

<Row>
<Cell Borders="Black" Paddings="5">
<Text Style="Style2">John</Text>
</Cell>
<Cell Borders="Black" Paddings="5">
<Text Style="Style2">Smith</Text>
</Cell>
<Cell Borders="Black" Paddings="5">
<Text Style="Style2">023-42-3432</Text>
</Cell>
</Row>
        ...

</Grid>

...

The other option is to load you xsl data into some item list and make a binding to that item list from the grid. Please take a look at the DataBinding/DataGrid and other examples available for the download as a part of the evaluation package at our web site.

Thank You,
Victor

Daniel Patfield

unread,
Apr 1, 2014, 6:49:28 PM4/1/14
to dot-net-...@googlegroups.com
I appreciate the answer. (Forgive my code below if it came out with many spaces)

The issue is - that I can't see any examples in the evaluation that refer to the <Grid> Element.

I am currently binding with a template call - and looping through the template with a recursive function (see code below).

But this is not a grid an needs rectangles and will not dynamically work with increasing data.

if binding includes the call to a template, how is that done with the GRID and ROW elements?
==============================================================================================

Section that calls the template:

<Section Size="Letter">

         <Site>

           <Group Left="20" Top="20" Height="500px" Width="750px">

             <!-- Approved Beneficiaries-->

             <Borders>

               <Left Color="Black" Width="5" />

               <Right Color="Black" Width="5"/>

               <Top Color="Black" Width="5"/>

               <Bottom Color="Black" Width="5"/>

             </Borders>

           </Group>

           <Group Top="24" Left ="24" Height="489px" Width="739px">

             <Borders>

               <Left Color="Black" Width="1" />

               <Right Color="Black" Width="1"/>

               <Top Color="Black" Width="1"/>

               <Bottom Color="Black" Width="1"/>

             </Borders>

           </Group>

            <Text Top="30" Left="60" Style="SectionLabel">Approved Beneficiaries</Text>

            <Group Top="55" Left ="54.5" Height="45.5px" Width="646.5px">

             <Borders>

               <Left Color="Black" Width="1" />

               <Right Color="Black" Width="1"/>

               <Top Color="Black" Width="1"/>

               <Bottom Color="Black" Width="1"/>

             </Borders>

           </Group>

           <Text Top="72" Left="60" Style="Standard_Bold">First Name</Text>

           <Text Top="72" Left="150" Style="Standard_Bold">Last Name</Text>

           <Text Top="72" Left="250" Style="Standard_Bold">SSN</Text>          

<xsl:call-template name="ApprovedBeneficiaryList">

             <xsl:with-param name="position">1</xsl:with-param>

             <xsl:with-param name="linenumber">90</xsl:with-param>

           </xsl:call-template>


     






Template

<!--Approved Beneficiaries List-->

<xsl:template match="ApprovedBeneficiaries/Row"><xsl:param name="top" /><xsl:param name="left" />

< !-- Rectangle element inserted here... -->

   <xsl:element name="Text"><xsl:attribute name="Style">Standard</xsl:attribute>

     <xsl:attribute name="Top"><xsl:value-of select="$top"/>

</xsl:attribute><xsl:attribute name="Left"><xsl:value-of select="$left"/>

</xsl:attribute><xsl:value-of select="FirstName"/></xsl:element>

<!-- Rectangle element inserted here... -->

<xsl:element name="Text"><xsl:attribute name="Style">Standard</xsl:attribute>

<xsl:attribute name="Top"><xsl:value-of select="$top"/>

</xsl:attribute><xsl:attribute name="Left"><xsl:value-of select="$left+90"/>

</xsl:attribute><xsl:value-of select="LastName"/></xsl:element>

<!-- Rectangle element inserted here... -->

<xsl:element name="Text"><xsl:attribute name="Style">Standard</xsl:attribute>

<xsl:attribute name="Top">xsl:value-of select="$top"/>

</xsl:attribute><xsl:attribute name="Left"><xsl:value-of select="$left+190"/>

</xsl:attribute><xsl:value-of select="SocialSecurityNumber"/></xsl:element></xsl:template>







 


Recursive Template Call:















































































































































































































































































































































































































































<xsl:template name="ApprovedBeneficiaryList">

<xsl:param name="position"/>

<xsl:param name="linenumber"/>

<xsl:if test="$position &lt;= count(//ApprovedBeneficiaries/Row)">

<xsl:apply-templates select="//ApprovedBeneficiaries/Row[position() = $position]">

<xsl:with-param name="top"><xsl:value-of select="$linenumber"/></xsl:with-param>

       <xsl:with-param name="left"><xsl:value-of select="60"/></xsl:with-param>

</xsl:apply-templates>

<xsl:call-template name="ApprovedBeneficiaryList">

<xsl:with-param name="position">

<xsl:value-of select="$position+1"/>

</xsl:with-param>

<xsl:with-param name="linenumber">

<xsl:value-of select="$linenumber+15"/>

</xsl:with-param>

</xsl:call-template>

</xsl:if>

</xsl:template>






Daniel Patfield

unread,
Apr 1, 2014, 6:52:29 PM4/1/14
to dot-net-...@googlegroups.com
Not sure what happened above - with all the spaces.  My apologies.

To summarize the above code, I have a template that represents the data from the original xml I showed you.
The xsl is calling that template and basically looping through the fields to create a table-like display.
With rectangles added, I make it look like a grid, but the rectangles and positioning are precarious to say the least.

I'm sure the grid element would be more appropriate, but how do I get it to present all data without looping?

siberix

unread,
Apr 1, 2014, 7:44:31 PM4/1/14
to dot-net-...@googlegroups.com
Hi Daniel,

Please read below:

1. The DataBinding examples are available as a part of the download package for the Report Writer for .NET only. However, they have pretty much the same logic and code as for the other versions of the Report Writer (WinStore, Silverlight, Android)

2. You can only bind our internal XML Grid / RowTemplate to an IEnumerable. There is no standard way to bind to XSL within our XML. You'd need to loop through your original XML and create Grid Rows / Cells in our format (take a look once again at the grid XML structure that i showed above) the same way you iterate and create the rectangles.

3. You don't need to use Site and Group as you'd limit your Grid content by the size of the Size. Site elements are non-breakable on pages.

Thank You,
Victor


Reply all
Reply to author
Forward
0 new messages