Solved

xsl dataview webpart groupby left characters of a string

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
onenote 2016 sync 40 238
Failed to upgrade SharePoint Products 8 74
Summing up list items in SharePoint online and a bit more 5 59
SharePoint 2013 Relational Database 8 90
Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

778 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