1

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

1 Answer 1

1

If you save a site that has a page on it that contains this Gannt view, you can import this exported solution in Visual Studio and see how SharePoint provisions the Gannt view.

This is an example from SP2103

        <View List="Lists/Taken" DisplayName="" Url="" DefaultView="FALSE" BaseViewID="8" Type="GANTT" WebPartOrder="0" WebPartZoneID="Left" ContentTypeID="0x" ID="g_0da33d7c_382a_4a9f_8bf3_7a4298c4df99" Hidden="TRUE"><![CDATA[<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Taken</Title>
  <FrameType>Default</FrameType>
  <Description />
  <IsIncluded>true</IsIncluded>
  <ZoneID>Left</ZoneID>
  <PartOrder>0</PartOrder>
  <FrameState>Normal</FrameState>
  <Height />
  <Width />
  <AllowRemove>true</AllowRemove>
  <AllowZoneChange>true</AllowZoneChange>
  <AllowMinimize>true</AllowMinimize>
  <AllowConnect>true</AllowConnect>
  <AllowEdit>true</AllowEdit>
  <AllowHide>true</AllowHide>
  <IsVisible>true</IsVisible>
  <DetailLink>/sites/OrgProject/Lists/Taken</DetailLink>
  <HelpLink />
  <HelpMode>Modeless</HelpMode>
  <Dir>Default</Dir>
  <PartImageSmall />
  <MissingAssembly>Kan dit webonderdeel niet importeren.</MissingAssembly>
  <PartImageLarge>/_layouts/15/images/ittask.png?rev=23</PartImageLarge>
  <IsIncludedFilter />
  <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
  <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
  <WebId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">00000000-0000-0000-0000-000000000000</WebId>
  <ListViewXml xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">&lt;View Name="{0DA33D7C-382A-4A9F-8BF3-7A4298C4DF99}" Type="GANTT" Hidden="TRUE" DisplayName="" Url="/sites/OrgProject/default.aspx" Level="1" BaseViewID="8" ContentTypeID="0x" ImageUrl="/_layouts/15/images/issuelst.png?rev=23"&gt;&lt;XslLink Default="TRUE"&gt;main.xsl&lt;/XslLink&gt;&lt;JSLink&gt;clienttemplates.js&lt;/JSLink&gt;&lt;Toolbar Type="Standard" /&gt;&lt;RowLimit Paged="TRUE"&gt;100&lt;/RowLimit&gt;&lt;ViewFields&gt;&lt;FieldRef Name="LinkTitle" /&gt;&lt;FieldRef Name="StartDate" /&gt;&lt;FieldRef Name="DueDate" /&gt;&lt;FieldRef Name="PercentComplete" /&gt;&lt;FieldRef Name="Predecessors" /&gt;&lt;FieldRef Name="AssignedTo" /&gt;&lt;FieldRef Name="GUID" /&gt;&lt;/ViewFields&gt;&lt;ViewData&gt;&lt;FieldRef Name="Title" Type="GanttTitle" /&gt;&lt;FieldRef Name="StartDate" Type="GanttStartDate" /&gt;&lt;FieldRef Name="DueDate" Type="GanttEndDate" /&gt;&lt;FieldRef Name="PercentComplete" Type="GanttPercentComplete" /&gt;&lt;FieldRef Name="Predecessors" Type="GanttPredecessors" /&gt;&lt;FieldRef Name="ParentID" Type="HierarchyParentID" /&gt;&lt;FieldRef Name="DueDate" Type="TimelineDueDate" /&gt;&lt;/ViewData&gt;&lt;/View&gt;</ListViewXml>
  <ListName xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">{$ListId:Lists/Taken;}</ListName>
  <ListId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">$ListId:Lists/Taken;</ListId>
  <ViewFlag xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">67108877</ViewFlag>
  <ViewFlags xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">Html TabularView Hidden Gantt</ViewFlags>
  <ViewContentTypeId xmlns="http://schemas.microsoft.com/WebPart/v2/ListView">0x</ViewContentTypeId>
</WebPart>]]></View>
1
  • Thanks Remko! It really helped! Your solution works well (tested on SP2010). Also i've noticed that there is a Type="GANNT" in your view definition. I just tried to add it to my version and it worked aswell!
    – Dmitry
    Apr 26, 2013 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.