Solved

xsl dataview webpart groupby left characters of a string

Posted on 2013-01-11
4
424 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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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