2

是否可以通过编程方式将共享点列表视图创建为甘特图视图?我以编程方式创建了列表视图,请参阅下面的代码

         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();
4

1 回答 1

2

你和你在这里的东西很接近。在将视图添加到 SPViewCollection 的行中,您需要使用不同的重载方法。方法选项列表在这里。您需要包含 SPViewCollection.SPViewType 类型的那个。这条线应该看起来像这样。

 SPView customView = allviews.Add(viewName, viewFields, myquery, 100, true, false, SPViewCollection.SPViewType.Gantt, false);
于 2011-07-29T15:24:35.377 回答