Solved

xsl dataview webpart groupby left characters of a string

Posted on 2013-01-11
4
416 Views
Last Modified: 2013-01-22
Hello -
I have a sharepoint 2010 list with a column "proposalID". The values in that column are
5555-01, 5555-02, 5555-03, 6666-01, 6666-02, etc.

I want to group by the 4 characters to the left of the dash.  So the grouping would display 3 items under 5555 and 2 items under the group 6666, etc.

In Sharepoint Designer, on my dataview webpart, I set the sorting by ProposalID - which renders the xsl as follows:

<xsl:when test="not ($dvt_groupfield)"><xsl:value-of select="ddwrt:NameChanged(string(@ProposalID), 0)" /></xsl:when>

My question is - how do I alter that xsl so that the grouping is done based on the 4 left characters?

I've not had luck with any substring syntax I've tried - so I'm stuck.

Thanks in advance.
0
Comment
Question by:Sue White
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 15

Assisted Solution

by:sharepointguru14
sharepointguru14 earned 500 total points
ID: 38773048
Are you using XSLT 1.0 or 2.0. Grouping can be handled differently between the 2 with 2.0 being much more straightforward.

Secondly you mentioned you aren't having success with substring syntax. What is the column type of your ProposalID column?

For 1.0 you will have to use Muenchian Grouping


For XSLT 2.0 you can use a foreach-group
<xsl:for-each-group select="ProposalID"
                    group-by="lower-case(substring(ProposalID,1,4))">
0
 

Author Comment

by:Sue White
ID: 38776026
Hello - I am using Sharepoint 2010 which most likely means xslt 1.  I went ahead and formatted my string to approximate yours to try it but  this
<xsl:when test="not ($dvt_groupfield)"><xsl:value-of select="ddwrt:NameChanged(string(substring(@ProposalID),1,4)) 0)" /></xsl:when>

throws an error that the number of aurgements are invalid.

The column type of ProposalID is text.

Thank you.
0
 

Accepted Solution

by:
Sue White earned 0 total points
ID: 38788109
It turns out that the substring format that sharepointguru14 suggests is correct - but because this is a dataview webpart, the ddwrt:NameChanged function is needed.  I had an extra ")" above in my syntax.  

I now have this working with:  
<xsl:when test="not ($dvt_groupfield)"><xsl:value-of select="ddwrt:NameChanged(string(substring(@ProposalID,1,4)) 0)" /></xsl:when>.

I've read sharepoint 2010 is still using XSLT 1.0 - so I'm not sure why sharepointguru14's 2.0 code is working in my dataview webpart - but happily it is.
0
 

Author Closing Comment

by:Sue White
ID: 38804790
initial suggestion got me started but I needed to work the remainer out myself to implement it
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question