Weird toolbar on Custom Document Library

I’ve been writing a custom document Library Definition. Well, I say I was writing – I actually created it in SharePoint, and used the Solution Generator in the Visual Studio Extensions for WSS3 to produce the CAML and .aspx files.

Having done this, however, one of the views in my document library was a bit strange. Somehow, for this one view, the ‘New’ and ‘Upload’ menus were missing:

Weird View (BaseType 3)

They were there for other views, just not this one. After examining the CAML (which sounds like some sort of euphemism) I found that the problem seemed to relate to the BaseViewID for the view. Continue reading “Weird toolbar on Custom Document Library”

Advertisements
Weird toolbar on Custom Document Library

Clean up SharePoint's UI with jQuery

So, the case management system I’m working on has a ‘Mailbox’ library. Really, it’s just an email enabled document library, with the address set to the name of the case. Anyway, when emails are received into this list, we’d like to show the subject, sender, cc, to addresses, and so on. It turns out that email enabling a document library does in fact add columns for those properties (but they’re not automatically added to the default view).

mailbox-page-default

Neat! Until you start looking at the code itself – then it sucks… Continue reading “Clean up SharePoint's UI with jQuery”

Clean up SharePoint's UI with jQuery

The Summary Toolbar in a ListView Web Part

Yesterday I was describing adding a ListView Web Part pointing at a specific view. I had a ListView Web Part which showed the right columns, but also showed the full toolbar:

case-comments-listview-2

…and I had a ListView which showed the Summary Toolbar, but didn’t show the right columns:

case-comments-listview-1

The Web Parts are defined identically, except for the BaseViewID property. So, what gives? Continue reading “The Summary Toolbar in a ListView Web Part”

The Summary Toolbar in a ListView Web Part

Pointing the ListViewWebPart at a particular view

So yesterday I described adding a ListViewWebPart to a Site Definition. This works – but how do you point the web part at a particular view?

This took a little figuring out. My ListViews were being defined in my ONET.xml file as:

<View List="Comments" BaseViewID="0" WebPartZoneId="Left">

Clearly the BaseViewID was a likely candidate – but what did it point to, and how could I define a view for my ListView? As is stood, My ListView kept appearing as:

case-comments-listview-1

Well, BaseViewID isn’t well documented, but it is actually the ID number of a view in the List Definition. I can’t say that I was able to see how to define a view for out ListView within our Site Definition itself.

If we open up our List Definition’s schema.xml file we see:

case-comments-list-definition-views

You can see that each of the views is assigned assigned a BaseViewID. I tried changing my BaseViewID to ‘1’ and my web part’s view changed to:

case-comments-listview-2

Great! This show’s the extra column I wanted – but it also shows the toolbar, which I didn’t. I really wanted the Summary Toolbar (the ‘Add new Item’ link, as in the top screenshot), but I’ll describe how I got that tomorrow.

Pointing the ListViewWebPart at a particular view

Pointing ListViewWebParts at lists

I was creating a site definition recently, and I wanted to use a ListView web part in it. List View Web Parts are a little strange; unlike other web parts they’re represented by a ‘View’ element inside the ‘File’ element for a page; it’s sort of saying that we want a view onto a list shown on this page. Looking at the out-of-box site definitions, they show things like:

<View List="104" BaseViewID="0" WebPartZoneID="Left" />

Here the ‘List’ attribute is the ‘Type’ id of the List, as defined in the list definition. Great – but what if (as in my case) you have two separate lists of the same type?

Well, it turns out that it also accepts a relative URL too. As the documentation says…

List – Optional Integer or Text. Specifies the type of list. This value can be either the ID of the template for a list (an integer), or the URL to a list provisioned in the site (a string). Best practice is to use Text, because Integer might not be specific enough (e.g., if there are two announcements lists in the site and you specify List=104).

So we can use:

<View List="Comments" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="1" />

Here the ‘List’ attribute is set to ‘Comments’, which is the URL to my ‘Comments’ list (no, it isn’t the name – ‘cos this list’s display name is ‘Case Comments’). And this works nicely. This is actually how some of the out-of-box site defintions work, but most of them refer to their lists by type.

Pointing ListViewWebParts at lists

Add a 'Create New Document' link to a page

Okay, so in SharePoint we’ve got document libraries. In them (provided we have the rights) we can go to the toolbar and click ‘New’, select a document type, and be shown a template document to start filling in. That’s pretty nice.

Often, though, we might want to surface those documents (or some of those documents) on a Page – either a Publishing Page or a Normal Page. We can do that with the ListView Web Part:

listview-with-add-new-link

As you can see, it can show an ‘Add new document’ link. We could also get it to show a toolbar very similar to the one in the List itself, or we can configure it to show nothing at all!

However, the ‘Add New Document’ link and the toolbar have quite different functionality. The ‘New’ button on the toolbar opens a new document, and lets you fill in the template, whereas the ‘Add new Document’ link simply takes you to the file upload page – so you don’t get a nice blank templated document to fill in. Continue reading “Add a 'Create New Document' link to a page”

Add a 'Create New Document' link to a page