Recently a co-worker contacted me about changing the XSLT in the I need to… web part so that items in the drop down are sorted by Title instead of the default, which appears to be ID. Here’s the working response I was able to provide back to him:
There is a sorting command available in xslt. It has to be placed within the XSLT area of the web-part, but you’ll have to make it XML Safe. Here’s the line to add:
<xsl:sort select="@Title"/>
I’ve modified the webpart file you sent to include this line. Here’s the text of the file with the changes highlighted:
<webParts><webPart xmlns="http://schemas.microsoft.com/WebPart/v3"><metaData><type name="Microsoft.SharePoint.Portal.WebControls.TasksAndToolsWebPart, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /><importErrorMessage>Cannot import this Web Part.</importErrorMessage></metaData><data><properties><property name="Height" type="string" /><property name="HelpMode" type="helpmode">Modeless</property><property name="ChromeType" type="chrometype">Default</property><property name="PageSize" type="int">-1</property><property name="Description" type="string">Displays tasks and tools from a list</property><property name="DataSourceID" type="string" /><property name="MissingAssembly" type="string">Cannot import this Web Part.</property><property name="ShowWithSampleData" type="bool">False</property><property name="AllowConnect" type="bool">True</property><property name="Xsl" type="string"><xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"version="1.0" exclude-result-prefixes="xsl ddwrt slwrt msxsl" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:slwrt="http://schemas.microsoft.com/WebParts/v3/SummaryLink/runtime"xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tnt="urn:schemas-microsoft-com:sharepoint:TasksAndToolsWebPart" ><xsl:param name="tasksAndtools_IsRTL" /><xsl:param name="tasksAndTools_Width" /><xsl:template match="/"><xsl:call-template name="MainTemplate"/></xsl:template><xsl:template name="MainTemplate" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><xsl:variable name="Rows" select="/dsQueryResponse/NewDataSet/Row"/><xsl:variable name="RowCount" select="count($Rows)"/><table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse; margin:0px;"><tr style="margin-top:3px;margin-bottom:1px;height:28px;border:0px;"><td style="padding-left:4px; white-space:nowrap ;"><xsl:if test="string-length($tasksAndTools_Width) != 0"><select id="TasksAndToolsDDID" class="ms-selwidth" style="width:{$tasksAndTools_Width}" size="1" title="Choose a task that you need to perform" ><option selected="true" value="0">Select Organization</option><xsl:call-template name="MainTemplate.body"><xsl:with-param name="Rows" select="$Rows"/></xsl:call-template></select></xsl:if><xsl:if test="string-length($tasksAndTools_Width) = 0"><select id="TasksAndToolsDDID" class="ms-selwidth" size="1" title="Choose a task that you need to perform"><option selected="true" value="0">Select Organization</option><xsl:call-template name="MainTemplate.body"><xsl:with-param name="Rows" select="$Rows"/></xsl:call-template></select></xsl:if></td><xsl:if test="$tasksAndtools_IsRTL = true()"><td style="padding-right:5px; padding-left: 14px;white-space:nowrap ;"><a id="TasksAndToolsGo" accesskey="G" title="Go" href="javascript:TATWP_jumpMenu()"><img title="Go" alt="Go" border="0" src="/_layouts/images/icongo01RTL.gif" style="border-width:0px;" onmouseover="this.src='/_layouts/images/icongo02RTL.gif'" onmouseout="this.src='/_layouts/images/icongo01RTL.gif'"/></a></td></xsl:if><xsl:if test="$tasksAndtools_IsRTL = false()"><td style="padding-right:14px; padding-left: 5px;white-space:nowrap ;"><a id="TasksAndToolsGo" accesskey="G" title="Go" href="javascript:TATWP_jumpMenu()"><img title="Go" alt="Go" border="0" src="/_layouts/images/icongo01.gif" style="border-width:0px;" onmouseover="this.src='/_layouts/images/icongo02.gif'" onmouseout="this.src='/_layouts/images/icongo01.gif'" /></a></td></xsl:if></tr></table></xsl:template><xsl:template name="MainTemplate.body" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"><xsl:param name="Rows"/><xsl:for-each select="$Rows"><xsl:sort select="@Title"/><xsl:variable name="GroupStyle" select="'auto'"/><option style="display:{$GroupStyle}" value="{ddwrt:EnsureAllowedProtocol(substring-before(@URL, ', '))}" ><xsl:value-of select="@Title"/></option></xsl:for-each></xsl:template></xsl:stylesheet></property><property name="ViewFlag" type="string" /><property name="FireInitialRow" type="bool">True</property><property name="TitleUrl" type="string" /><property name="NoDefaultStyle" type="string" /><property name="ListName" type="string" null="true" /><property name="TasksAndToolsWebUrl" type="string">/finance/ratemanagement/ba</property><property name="AllowEdit" type="bool">True</property><property name="ParameterBindings" type="string" /><property name="CatalogIconImageUrl" type="string" /><property name="Default" type="string" /><property name="ChromeState" type="chromestate">Normal</property><property name="DataSourcesString" type="string" /><property name="Direction" type="direction">NotSet</property><property name="FilterCategory" type="string">Visible</property><property name="CacheXslStorage" type="bool">True</property><property name="AllowMinimize" type="bool">True</property><property name="UseSQLDataSourcePaging" type="bool">True</property><property name="CacheXslTimeOut" type="int">86400</property><property name="FilterFieldValue" type="string">Yes</property><property name="ExportMode" type="exportmode">All</property><property name="TasksAndToolsListName" type="string">ineedto</property><property name="HelpUrl" type="string" /><property name="SampleData" type="string"> <dsQueryResponse> <NewDataSet> <Row /> </NewDataSet> </dsQueryResponse> </property><property name="AllowClose" type="bool">True</property><property name="DisplayName" type="string" /><property name="TitleIconImageUrl" type="string" /><property name="TasksAndToolsWidth" type="string">px;</property><property name="ViewContentTypeId" type="string" /><property name="XslLink" type="string" null="true" /><property name="AllowZoneChange" type="bool">True</property><property name="Hidden" type="bool">False</property><property name="DataFields" type="string" /><property name="Title" type="string">See My Organization</property><property name="Width" type="string" /><property name="AllowHide" type="bool">True</property></properties></data></webPart></webParts>
Just export the webpart from the site and make the change to the XSLT and then import the webpart back into the site.
No comments:
Post a Comment