2011-07-29 40 views
2

是否可以通過編程方式創建SharePoint列表視圖作爲Gant圖表視圖?我創建列表視圖編程是否可以通過編程方式創建SharePoint列表視圖作爲Gant圖表視圖?

  var web = (SPWeb)properties.Feature.Parent; 

     SPList list = web.GetList(SharedDocumentListUrl); 
     SPViewCollection allviews = list.Views; 
     string viewName = "Document Review Summary"; 
     System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection(); 
     viewFields.Add(EYWorkProductIndicator); 
     viewFields.Add(EYPaperProfile); 
     viewFields.Add(DocIcon); 
        string myquery = "<Where><Eq><FieldRef Name='Status' /><Value Type='Choice'>In Review</Value></Eq></Where>" 
      + "<OrderBy><FieldRef Name='LinkFilename' Ascending='True' /></OrderBy>"; 
     SPView customView = allviews.Add(viewName, viewFields, myquery, 100, true, false); 
     customView.XslLink = "eymain.xsl"; 
     customView.Update(); 

回答

2

你是非常接近你在這裏有什麼。在將視圖添加到SPViewCollection的行中,您需要使用不同的重載方法。方法選項列表是here。您需要包含SPViewCollection.SPViewType類型的那個。這條線應該看起來像這樣。

SPView customView = allviews.Add(viewName, viewFields, myquery, 100, true, false, SPViewCollection.SPViewType.Gantt, false); 
相關問題