Solved

xsl dataview webpart groupby left characters of a string

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Last week I faced a strange issue recently, i have deployed SharePoint 2003 servers for one project and one of the requirements was to open SharePoint site from same server. when i was trying to open site from the same server i was getting authentic…
The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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