Wednesday, March 14, 2012

Unique Item

If we have a list with items which one of the columns can be the same, like this for example:
Offices
Location
Office 1
Israel
Office 2
Italy
Office 3
Israel

And we need to select a distinct item from this list in a DVWP. Add this row to your dvt_1.body
<xsl:for-each select="$Rows[not(@Location = preceding-sibling::*/@Location)]">
This will check the preceding sibling if it has the same name, if true it won’t display that item if it is already exists.
For example:
1.   <xsl:template name=dvt_1.body>  
2.     <xsl:param name=Rows/>  
3.     <xsl:for-each select=$Rows[not(@Location = preceding-sibling::*/@Location)]>  
4.       <xsl:call-template name=dvt_1.rowview” />  
5.     </xsl:for-each>  
6.   </xsl:template>  

No comments:

Post a Comment