Set Properties on a List View Web Part…


Hey buddies. Smile 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 Sad smile.

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=14.0.0.0, 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. Smile

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s