Solved

xsl dataview webpart groupby left characters of a string

Posted on 2013-01-11
4
372 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
  • 3
4 Comments
 
LVL 15

Assisted Solution

by:sharepointguru14
sharepointguru14 earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
initial suggestion got me started but I needed to work the remainer out myself to implement it
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now