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:
…and I had a ListView which showed the Summary Toolbar, but didn’t show the right columns:
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
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:
Or you can download it as code.
So, what I did was I copied my ‘1’ view, and created a new ‘2’ view:
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:
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.