I'm trying to put gantt view of the list on the default page of the site. For common views, i'm using module with the default.aspx page and view i need this way:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="DefaultPage">
<File Url="default.aspx" Path="DefaultPage\default.aspx" IgnoreIfAlreadyExists="TRUE">
<View List="Lists/TestList" BaseViewID="1" WebPartZoneID="Left" WebPartOrder="1">
<![CDATA[
<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage>Cannot import this Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">Test</property>
<property name="AllowConnect" type="bool">True</property>
<property name="ChromeType" type="chrometype">TitleOnly</property>
<property name="AllowClose" type="bool">False</property>
</properties>
</data>
</webPart>
</webParts>
]]>
</View>
</File>
</Module>
but if I use the same code for gantt view (by changing BaseViewID) i get a common grid view, not a gantt view. I googled and found out that i need to use ListViewWebPart instead. I tried the following module:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="DefaultPage">
<File Url="default.aspx" Path="DefaultPage\default.aspx" IgnoreIfAlreadyExists="TRUE">
<View List="Lists/TestList" BaseViewID="9" WebPartZoneID="Left" WebPartOrder="1">
<![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>Gantt view</Title>
</WebPart>
]]>
</View>
</File>
</Module>
where Lists/TestList is a task list and BaseViewID="9" - gantt view. but i still get a common grid view (table instead of the diagram) on the default.aspx page How can tell ListViewWebPart to render my view as a Gantt view?
UPD: To make the above code work, just need to add Type="GANTT" in the view definition:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="DefaultPage">
<File Url="default.aspx" Path="DefaultPage\default.aspx" IgnoreIfAlreadyExists="TRUE">
<View List="Lists/TestList" BaseViewID="9" Type="GANTT" WebPartZoneID="Left" WebPartOrder="1">
<![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>Gantt view</Title>
</WebPart>
]]>
</View>
</File>
</Module>
</Elements>
or use the code suggested by Remko