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

How to display a URL hyperlink in a CQWP

By peter.stilgoe









In the relevant template section in itemstyle.xsl add a line something like (replacing the column name with the your column containing the URL):

LiveView: <a href="{substring-before(@Live_x005F_x0020_View, ',')}">Click here</a>




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

How to display a URL in a DVWP using the XSLT ‘substring’ function

By peter.stilgoe









The code below will use the URL held in View_x005F_x0020_Flow but will only use the URL part before the comma

ie original URL

www.petestilgoe.com/&=testing,testing123

<a href="{substring-before(@View_x005F_x0020_Flow, ',')}">View Flow</a></td></tr>

URL after using the above code is:

www.petestilgoe.com/&=testing

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