Friday, April 22, 2011

Module feature: ListViewWebPart how to hide the toolbar?

 I have a module feature for the default page with ListViewWebPart on it:

<View Type="CALENDAR" List="$Resources:core,lists_Folder;/DiscussionReview" BaseViewID="2" WebPartZoneID="BottomLeft" WebPartOrder="1" Scope="Recursive">
            <WebPart xmlns="">
            <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
            <Title>At-Risk Discussions</Title>
I want to hide the toolbar on that webpart.

I can do it through UI (Edit Page-> (If the webpart in the zone - I can access to the web part properties)-> chose a webpart and click edit -> Modify Shared web part->Toolbar Type->No Toolbar):

But I want to make this change in my SharePoint project and make it deploybale.
The Toolbar Type is not a property of the webpart, but the view itself.
SPView.ToolbarType Property (MSDN)

In this case, I can change this Toolbar Type property in the view in schema.xml:

<Toolbar Type="None">

P.S. To my delight - this change got propagated to already created list without any complications.