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:
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:
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:
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.