MultiSelectDisplay on Custom Multi-Value Lookup

Jun 27, 2012 at 6:47 PM
Edited Jun 27, 2012 at 6:52 PM

I have two (2) lists. My column (@MyLookupCol) of concern is in List A which is a multi-select lookup column. The source of which is the “Title” column of another list; List B.

I am building a custom dashboard interface from scratch (using SPF2010). As part of the dashboard I have built a Muenchian type grouping with counts for totals on certain columns. This is working great and groups the multi-selected values accordingly. However, the problem I am having is when I display the values from the @MyLookupCol. (not the @MyLookupCol since I dont want the hyperlinks) the values are rendering as 'ID;#' and not just ';#' as shown (have left the count column out for brevity):

 

1;#Breach of Contract or Warranty
 
1;#Breach of Contract or Warranty;#13;#Real Estate 
  
1;#Breach of Contract or Warranty;#7;#General Litigation-Insurance
   
11;#Premises Liability
  
12;#Products Liability
  
13;#Real Estate
  
14;#Retaliation 
  
21;#Other  

3;#Discrimination 

3;#Discrimination;#14;#Retaliation

3;#Discrimination;#14;#Retaliation;#19;#Wage and Hour
  
7;#General Litigation-Insurance

9;#Intellectual Property

 

I have implemented the MultiSelectDisplay with some modifications to the substrings items but for some reason the values are not rendering as expected. What is happening is all of the values are pre-fixed with the MultiSelectSeparator and it is not removing all of the id's from the strings as shown below (again have left the count column out for brevity):

 

|Breach of Contract or Warranty

Breach of Contract or Warranty|13||Real Estate 

Breach of Contract or Warranty|7||General Litigation-Insurance

|Premises Liability

|Products Liability

|Real Estate

|Retaliation

|Other

|Discrimination

Discrimination|14||Retaliation

Discrimination|14|Retaliation|19||Wage and Hour

|General Litigation-Insurance

|Intellectual Property

 

Here is the XSLT for the above for reference:

 

<xsl:key name="claimtypes" match="Row" use="@ClaimTypeLkUp"/>

   <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls">
      <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row/@ClaimTypeLkUp."/>
      <table border="0" width="100%" cellpadding="2" cellspacing="0">
         <tr valign="top">
            <th class="ms-vh" nowrap="nowrap">Claim Type</th>
            <th class="ms-vh" nowrap="nowrap">Totals</th>
         </tr>
         <xsl:for-each select="//Row[generate-id() = generate-id(key('claimtypes', @ClaimTypeLkUp)[1])]">
            <xsl:sort select="@ClaimTypeLkUp"/>
            <xsl:for-each select="key('claimtypes', @ClaimTypeLkUp)">
               	<xsl:call-template name="ClaimTypes.RowView" />
            </xsl:for-each>
         </xsl:for-each>
      </table>         
   </xsl:template>
   
   <xsl:template name="ClaimTypes.RowView">
      <xsl:variable name="NewSortValue" select="ddwrt:NameChanged(string(@ClaimTypeLkUp.), 0)"/>
      <xsl:variable name="NiceDisplay">
		  <xsl:call-template name="MultiSelectDisplay"> 
		    <xsl:with-param name="MultiSelectValue" select="@ClaimTypeLkUp."/>
		    <xsl:with-param name="MultiSelectDelimiter" select="';#'"/>
		    <xsl:with-param name="MultiSelectSeparator" select="'|'"/>
		  </xsl:call-template>
		</xsl:variable>
      <xsl:if test="string-length($NewSortValue) &gt; 0">
         <tr id="group0{generate-id()}">
            <td>
               <xsl:value-of select="$NiceDisplay"/>
            </td>
			<td>
				<xsl:value-of select="count(key('claimtypes', @ClaimTypeLkUp))"></xsl:value-of>
			</td>
         </tr>
      </xsl:if>
   </xsl:template>  
   
	<xsl:template name="MultiSelectDisplay"> 
        <xsl:param name="MultiSelectValue"/> 
        <xsl:param name="MultiSelectDelimiter"/> 
        <xsl:param name="MultiSelectSeparator"/> 
        <xsl:choose>
            <xsl:when test="contains($MultiSelectValue, $MultiSelectDelimiter)">
                <xsl:value-of select="concat(substring-before(substring-after($MultiSelectValue, $MultiSelectDelimiter), $MultiSelectDelimiter), $MultiSelectSeparator)" disable-output-escaping="yes"/> 
                <xsl:call-template name="MultiSelectDisplay"> 
                    <xsl:with-param name="MultiSelectValue" select="substring-after($MultiSelectValue, $MultiSelectDelimiter)"/> 
                    <xsl:with-param name="MultiSelectDelimiter" select="$MultiSelectDelimiter"/> 
                    <xsl:with-param name="MultiSelectSeparator" select="$MultiSelectSeparator"/> 
                </xsl:call-template>
            </xsl:when> 
            <xsl:otherwise>
            	<xsl:value-of select="$MultiSelectValue" disable-output-escaping="yes"/>  
            </xsl:otherwise> 
        </xsl:choose> 
    </xsl:template> 

 

 I at first had modified:

<xsl:with-param name="MultiSelectValue" select="substring-after($MultiSelectValue, $MultiSelectDelimiter)"/> 

To:

<xsl:with-param name="MultiSelectValue" select="substring-after(substring-after($MultiSelectValue, $MultiSelectDelimiter), $MultiSelectDelimiter)"/> 

But that removed all of the rows with just single values but left the MultSelectSeparator except for a couple of rows as shown below:

 

|

Breach of Contract or Warranty|| 

Breach of Contract or Warranty||

| 

|

|

|

|

| 

Discrimination||

Discrimination|Retaliation|| 

|

|

 

 

Any help or clarification on how to resolve this would be greatly appreciated!

 

Thanks!

Aug 21, 2012 at 6:20 PM

TranseoSP,

I solved this on a similar issue with multiple select people picker not displaying properly,  but modifying the MultiSelectDisplay template as follows:

<!-- http://spxslt.codeplex.com -->
  <xsl:template name="MultiSelectDisplay">
    <xsl:param name="MultiSelectValue"/>
    <xsl:param name="MultiSelectDelimiter"/>
    <xsl:param name="MultiSelectSeparator"/>
    <xsl:choose>
      <xsl:when test="contains($MultiSelectValue, $MultiSelectDelimiter)">
        <xsl:variable name="before" select="substring-before($MultiSelectValue, $MultiSelectDelimiter)"/>
        <xsl:if test= "string(number($before))='NaN'">
          <xsl:value-of select="concat($before, $MultiSelectSeparator)" disable-output-escaping="yes"/>
        </xsl:if>
        <xsl:call-template name="MultiSelectDisplay">
          <xsl:with-param name="MultiSelectValue" select="substring-after($MultiSelectValue, $MultiSelectDelimiter)"/>
          <xsl:with-param name="MultiSelectDelimiter" select="$MultiSelectDelimiter"/>
          <xsl:with-param name="MultiSelectSeparator" select="$MultiSelectSeparator"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test= "string(number($MultiSelectValue))='NaN'">
          <xsl:value-of select="$MultiSelectValue" disable-output-escaping="yes"/>
        </xsl:if>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

and calling it as follows:

<xsl:call-template name="MultiSelectDisplay">
                    <xsl:with-param name="MultiSelectValue" select="@AssignedTo"/>
                    <xsl:with-param name="MultiSelectDelimiter" select="';#'"/>
                    <xsl:with-param name="MultiSelectSeparator" select="' | '"/>
                  </xsl:call-template>

This workaround will fail if a value in the multi select is actually a number. 

Originally I tried to just display every second value, but on occasion, I found that one of the values did not start with a numberic value first. ( Name1;#242;#Name2;#342),

HTH

Tom

Coordinator
Sep 11, 2012 at 1:58 PM

I originally wrote this template to work with simple multi-select columns. It looks like the two of you are working with multi-select lookup columns. Tom's solution looks good, but I haven't tested it. I'm not sure that it would work with Person or Group columns, though.

M.

Coordinator
Sep 11, 2012 at 1:58 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Sep 11, 2012 at 2:21 PM

My scenario was on a Person or Group column, where allow multipe selections = "Yes", and only allow selection of: "People Only".

I have not tested other scenarios.

Tom