Hey buddies. Ever wanted to set some properties on a List View Web Part? Had issues doing it? End up with no solution? Here you have the solution.
Recent past I had a requirement to create a page instance with a Calendar Month view embed in a web part zone. So my first thoughts was to create a page manually, add the required calendar View to it, set all custom properties (hide chrome is the only thing I had to do) and export. Oh Gosh, at the last step I realized you cannot export the Calendar View .
Any how reading through the net I found a way to export the Calendar List View. But it contains some GUIDs that refers to the Default View of the calendar, that is created when the web part is provisioned and that I cannot predict before hand. Now what?
Then reading some more articles on the web I found there is a way to set web part properties inside a CDATA section of the view. The Views are generated from the Microsoft.SharePoint.WebPartPages.ListViewWebPart.
<View List="Lists/PluginCalendar" BaseViewID="2" Type="CALENDAR" Scope="Recursive" RecurrenceRowset="TRUE" WebPartZoneID="TopWebZone" WebPartOrder="0"> <![CDATA[ <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"> <Assembly>Microsoft.SharePoint, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly> <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart </TypeName> <Title>Calendar of Events</Title> <FrameType>None</FrameType> </WebPart> ]]> </View>
So finally I was able to set the web part properties inside a CDATA section and get the thing done.