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?

Well, both these ListViews use Views defined in our List Definition. It turns that the Views themselves define the toolbar for the ListView Web Part

view

Here you can see that my view (the top image in this post) is using the ‘Standard’ toolbar. Is there a ‘Summary’ one?

Well, no. I found a post by Nick Sevens that points out that you actually need quite a long chunk of XML. To repeat it from my system:

case-comments-toolbar

Or you can download it as code.

So, what I did was I copied my ‘1’ view, and created a new ‘2’ view:

case-comments-list-definition

You can see I changed the View node quite a lot – we were not providing this as a page, so I hid it, and didn’t define a file for it to be displayed in. I gave it a new BaseViewID. And at the bottom, I added the Summary Toolbar XML mentioned above. The result was:

listview-3

This was what I wanted!

It does seem a bit counter intuitive that for the ListView Web Part I’m defining myview in the List Definition itself, but I’ve not been able to find a way to define the View in the Site Definition’s XML. It’s also a bit of a pain having to manually create my ‘ListView with Summary Toolbar’ view, but actually it doesn’t take very long – you can cut and paste most of it, including the toolbar. It’s just a bit of a pain to try to figure out.

The Summary Toolbar in a ListView Web Part

3 thoughts on “The Summary Toolbar in a ListView Web Part

  1. Hi,

    I understaood this, but i was not able to understand that where i can see the list view web part. In one blog it was written that it is present in the site collection web part gallery but couldn’t find that….And how various lists become part of this web part

  2. Hmm. Well, the ListView Web Part shouldn’t appear in the Web Part gallery – the lists it shows are different for each site, yet the Web Part Gallery is at the site collection scope.

    ListViews are a bit special. Normally, they just appear in the ‘Add Web Part’ dialog for the site you’re in.

    What I was doing, though, was creating a Site Definition, where I wanted to show a listview web part with a particular format. I was building that into a List Definition used by my Site definition.

    Anyway, to this shows the code used to add a ListView web part to a site when it’s initially provisioned:

    http://www.novolocus.com/2009/05/14/pointing-the-listviewwebpart-at-a-particular-view/

    Yup, it’s a node marked ‘View’ rather than a web part. Like I said, List View web parts are special

  3. Mike McDonoguh says:

    You are my hero! Thank you for this, I’ve been fighting with this for a couple of days now! Thank you!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.