Side note: I thought I had blogged on this before, but I can't find any evidence that I did...
One of the more daunting tasks of SharePoint development is modifying the schema.xml files of a List definition; the CAML of the ViewHeader, ViewBody, ViewFooter, etc elements is tedious to wade through. Granted, if you need a custom view, you can simply copy and paste from an existing view, then modify as needed, but that adds over 1600 lines of XML to your Schema file. Not much fun.
Turns out there is a much simpler way: If you don’t have any need for custom rendering of the View, you can use one of the standard styles defined in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL\XML\VWSTYLES.XML file. These are the same views that are accessible from the SharePoint UI under View – Modify This View - Style group.
To apply one of these styles, use the ID attribute of the style from the VWSTYLES.XML file and add a <ViewStyle ID=”x” /> element to your View in the schema file. Then safely remove the ViewHeader, ViewFooter, ViewBody, ViewEmpty, GroupByHeader, GroupByFooter, PagedRowset, PagedClientCallbackRowset, and PagedRecurrenceRowset tags. That's a lot of XML saved.
Internally, the SPView.ApplyStyle() method is then called, and any View styles defined in the Schema file are overridden by the ViewStyle definition. (It is unknown how/if PagedClientCallbackRowset, PagedRecurrenceRowset, PagedRowset and other View child elements get their values set by the ViewStyle – that part of the code base is obfuscated.)
Labels: howto, moss, sharepoint