tags:

views:

1942

answers:

5

I want to show the documents in my document library grouped by category. The category is a lookup column that I added that allows for multiple values. Unfortunately this breaks the "group by"-functionality completely. Is there a programmatic solution to this problem?

A: 

I don't think what you are trying to do is possible. When grouping items/documents, you display them in different groups based on a grouping value. I don't think SharePoint has support for adding a single item to multiple groups. With multiple values in the grouping field its' impossible to know which group to add the item/document to. I am not sure if this is an error or if it's by design.

Thomas Favrbo
A: 

Thomas is correct, this is by design as the item would have to appear multiple times in different groups. It is worth noting that this is possible via the web services, however.

See why I was getting duplicate rows from the sharepoint lists web service

And no, I've no idea why the lists webservice will do it, but the API won't.

Andy Burns
+2  A: 

There is one way... It's complex and ugly - but it should work :)

It is possible for you to write you own view for at list (HTML, JavaScript and all). The VWSTYLES.xml file in the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\XML folder, contains the HTML and JavaScript for the default SharePoint view styles - getting your inspiration from this, you can create your own view style, where you can do anything you want!

The problem is, that SharePoint don't have any way to deploy your custom view style - this is where the ugly part comes in - you have two options for deploying your view style.

  1. Add you code directly to the VWSTYLE.xml/Edit a copy of it and override it with a feature

    Pros:

    You will still be able to edit the view from the SharePoint interface

    Cons:

    You override a default SharePoint file - your work can be overridden by a SharePoint update.

    Your view style will be available on every list in SharePoint.

  2. Create your view programmatically on the list

    Pros:

    You don't override any default SharePoint files.

    You can control which list uses your view

    Cons:

    You wont be able to edit the view thru the SharePoint interface

I've used method 2 a couple of times myself - and it works... but it's not pretty! :)

Brian Jensen
A: 

Hi Brian,

Even if it's ugly, can you tell us how you create your view programmatically? I have no idea how you could do that.

A: 

Check out this link as well. Access supports this functionality without having to do much ugly code. http://office.microsoft.com/en-us/access/HA012337221033.aspx