In a Sharpoint 2010 project, I have a custom content type, which inherits the standard Task content type, and a custom list template, with items of this content type (everything is done in XML and code, not ‘clicked-through’).
I would like to add a Gantt chart to my list. I can do it using the web interface but I would like to have it in code. So I have done it manually, opened Sharepoint Manager, previewed the view schema and, with minor but necessary modifications, copied it to my list schema. So I ended up with a view which looks more less like this:
<View WebPartZoneID="Main" Type="GANTT" DisplayName="Gantt Chart" Url="gantt.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/issues.png" SetupPath="pages\viewpage.aspx">
<Query>
<OrderBy>
<FieldRef Name="ID" />
</OrderBy>
</Query>
<ViewFields>
<FieldRef Name="Attachments" />
<FieldRef Name="ID" />
<FieldRef Name="DocIcon" />
<FieldRef Name="LinkTitle" />
<FieldRef Name="AssignedTo" />
<FieldRef Name="Status" />
<FieldRef Name="Priority" />
<FieldRef Name="StartDate" />
<FieldRef Name="DueDate" />
<FieldRef Name="MyCustomField" />
<!-- other FieldRefs for my custom fields -->
</ViewFields>
<ViewData>
<FieldRef Name="StartDate" Type="GanttStartDate" />
<FieldRef Name="DueDate" Type="GanttEndDate" />
<FieldRef Name="Title" Type="GanttTitle" />
<FieldRef Name="PercentComplete" Type="GanttPercentComplete" />
<FieldRef Name="Predecessors" Type="GanttPredecessors" />
</ViewData>
<RowLimit Paged="TRUE">30</RowLimit>
<Aggregations Value="Off" />
</View>
But this doesn’t work. The view is visible on the list, but when I open it, a blank page appears. Because of some reason, when I preview my custom view in Sharepoint Manager the <ViewData> tag is not there. I may add this tag manually in Sharepoint Manager and then the view magically starts to work. However, the tag, because of some reason, is not deployed with the rest of the view.
Any suggestions as to how to make the tag deploy?
I am not sure what is wrong in your declaration but i was able to add working defininition to schema. Here it is my definition:
Just note that BaseViewID should be unique in scope and I dont use ContentTypeID.
Also Computed and calculated fields doenot working here so you should create new simple text field and populate them in event recievers.