How to total a column of values in a Sharepoint DVWP

By peter.stilgoe









To total a column of values in a Sharepoint DVWP use:

<xsl:value-of select="sum(/dsQueryResponse/Rows/Row/@TotalHoursWorked)" />

To do something similar in Xpath with formatting:

format-number(sum(/dsQueryResponse/Rows/Row/@TotalHoursWorked), '#,##0.00;-#,##0.00')




Share

Leggi tutto

Sharepoint CQWP: XSL to link document icon to document and open in edit mode

By peter.stilgoe









The xsl code will display & make the document icon link to the sepcific document & open it in edit mode in your content query webpart:

<a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
                   <xsl:attribute name="onclick">
                     <xsl:value-of select="@OnClickForWebRendering"/>
                   </xsl:attribute>
                 </xsl:if>
                 <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
                   <xsl:attribute name="onclick">
                     <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
                   </xsl:attribute>
                 </xsl:if> 

                 <img class="image" src="{@DocumentIconImageUrl}" title="" />
				 </a>




Share

Leggi tutto

Sharepoint CQWP How to format date from mm/dd/yyyy to UK dd/mm/yyyy

By peter.stilgoe









To format your Sharepoint content query webpart to UK date format do the following:

In your ItemStyle.xsl add the following line to your declarations:

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

Then use the following line to display & format your date field in UK date format:

<xsl:value-of disable-output-escaping="no" select="ddwrt:FormatDate(string(@Modified), 2057, 5)" />

@Modified is your date field that you want to format




Share

Leggi tutto

Sharepoint 2010: Lookup columns in Data Views using SOAP & REST webservices

By peter.stilgoe









If you are using a webservice & a dataview to display list data across sites in Sharepoint 2010 you may come across this problem when displaying lookup columns.

A lookup field is stored in the format “ID;#Text”

When using a REST data connection the values returned for the lookup column is just the ID part of that item in the lookup list ie. “01″, I couldnt find a way how to return the text part of the lookup.

If you use a SOAP data connection it will retun the whole string ie, “01;#Blue”, so now we are getting the value but we dont want to display the the ID part or the ‘;#’ part. This is easily done changing the XSLT from

<xsl:value-of select="@ows_Colour_x0020_Status"/>

to

<xsl:value-of select="substring-after(@ows_Colour_x0020_Status, ';#')" />

Now in your dataview instead of displaying “01;#Blue”, you will just be displaying the text value “Blue”.




Share

Leggi tutto

Using a CQWP to display items from a link list

By peter.stilgoe









If you point an OOTB CQWP to a Sharepoint Link List it will surface your links but each link will be displayed as (Blank) as its defaulting to display the Title column which is blank, it also links to the Link Item page as opposed to linking throught to the actual Link URL.

To fix this we need to:

1) Tell the CQWP to get the “URL” field from the list

- Add the CQWP to the page where you want to display the link list items

- Export the CQWP to a file (On the CQWP Edit menu click ‘Export’)

- Open the CQWP file in your editor & find

<property name="CommonViewFields" type="string" />

replace this with

<property name="CommonViewFields" type="string">URL,text</property>

(This is telling the CQWP to recognise the ‘URL’ column)

- Save this CQWP file & upload it back to you Web Part Gallery.

2) Create a new itemstyle for a link list that will render the link using the URL field instead of the URL to the link item page

- In your site collection goto

Site Library –> XSL Style Sheets –> ItemStyle.xsl

- Edit ItemStyle.xsl & add the template code below, add this below the last

</xsl:template>

in the file.

<xsl:template name="LinkList" match="Row[@Style='LinkList']" mode="itemstyle">
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@URL"/>
<xsl:with-param name="UrlColumnName" select="'URL'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">
<xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
</xsl:variable>
<div id="linkitem" class="item" >
<div class="bullet link-item">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a>
<xsl:attribute name="href">
<xsl:value-of select="substring-before($DisplayTitle,', ')">
</xsl:value-of>
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="@Description">
</xsl:value-of>
</xsl:attribute>
<xsl:value-of select="substring-after($DisplayTitle,', ')">
</xsl:value-of>
</a>
</div>
</div></xsl:template>

- Save the file & check back in

- Now go back to the page where you want to display links from a Sharepoint Link List & add your new webpart

- Open the webpart properties & goto Presentation –> Styles –> ItemStyle

- You should have the newly added ‘LinkList’ style, select this & click OK

Now your CQWP should be displaying your link list URLs as desired.




Share

Leggi tutto

Displaying HTML in the Dataview Webpart (DVWP)

By peter.stilgoe









If you try & display rich html columns or any other columns that uses HTML in a DVWP it will display as the actual HTML as opposed to outputting it as HTML formatted text.

If you added your data using Sharepoint designer “Insert Selected Fields” you need view your DVWP code in SPD & search for:

xsl:value-of select=”@MyHTMLFormattedColumn”

and replace it with

xsl:value-of disable-output-escaping=”yes” select=”@MyHTMLFormattedColumn”

Now your data in this column will display as you expected ie. formatted with the HTML code applied.

Note: In SPD 2010 you will need to convert your DVWP to XSLT, On the ribbon:

List View Tools –> Design –> Customize XSLT

Share

Leggi tutto