Friday, 4 April 2008

Using DataFormWebPart to render the List

1. Open the page in Sharepoint Designer
2. Insert the DataformWebpart
3. Select the required list
4. Switch to code pane of SPD.

Replace the entire XSL
<xsl>
<?xml:namespace prefix = xsl />
<xsl:stylesheet version="1.0" x="http://www.w3.org/2001/XMLSchema" d="http://schemas.microsoft.com/sharepoint/dsp" prefixes="xsl msxsl ddwrt" ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" asp="http://schemas.microsoft.com/ASPNET/20" __designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xsl="http://www.w3.org/1999/XSL/Transform" msxsl="urn:schemas-microsoft-com:xslt" sharepoint="Microsoft.SharePoint.WebControls" ddwrt2="urn:frontpage:internal">

<xsl:output indent="no" method="html"></xsl:output>
<xsl:decimal-format nan=""></xsl:decimal-format>
<xsl:param name="dvt_apos">'</xsl:param>
<xsl:variable name="dvt_1_automode">0</xsl:variable>
<xsl:template match="/">
<xsl:call-template name="dvt_1"></xsl:call-template>
</xsl:template>
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">Table</xsl:variable>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"></xsl:variable>
<table cellspacing="0" cellpadding="2" width="100%" border="0">
<tbody><tr valign="top">
<xsl:if test="$dvt_1_automode = '1'" cf_ignore="1">
<th class="ms-vh" width="1%"></th>
</xsl:if>
<th class="ms-vh">Title</th>
</tr>
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"></xsl:with-param>
</xsl:call-template>
</tbody></table>
</xsl:template>
<xsl:template name="dvt_1.body">
<xsl:param name="Rows"></xsl:param>
<xsl:for-each select="$Rows">
<span class="ms-acclink">
<xsl:text escaping="yes">&nbsp;</xsl:text>
<xsl:text></xsl:text>
<xsl:text escaping="yes">&nbsp;</xsl:text>
</span>

<a>
<xsl:attribute name="href"><xsl:value-of select="@NavigateURL"></xsl:value-of></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="@Location"></xsl:value-of>-- <xsl:value-of select="@WorkCity"></xsl:value-of></xsl:attribute>
<xsl:value-of select="@Title"></xsl:value-of>
</a>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet></xsl>
<parameterbindings>
<parameterbinding name="ListName" defaultvalue="TopNavigation" location="None">
<parameterbinding name="WebURL" defaultvalue="/" location="None">
<parameterbinding name="dvt_apos" location="Postback;Connection">
<parameterbinding name="UserID" defaultvalue="CurrentUserName" location="CAMLVariable">
<parameterbinding name="Today" defaultvalue="CurrentDate" location="CAMLVariable">
</parameterbindings>

No comments: