如何以编程方式将时间轴Webpart添加到页面SharePoint 2013

时间:2018-10-04 09:46:24

标签: sharepoint-2013

我已经在SharePoint中以编程方式创建了一个Webpart页面,并成功使用JSOM代码将内容编辑器Webpart添加到了同一页面。但是我无法将时间轴Web部件添加到同一页面。我从共享点设计器获得的内容编辑器XML代码已经使用过。但是我无法获取与时间轴Webpart相对应的xml。我已经添加了下面使用的内容编辑器Webpart代码。

var clientContext = new SP.ClientContext(siteUrl);

var oFile = clientContext.get_web().getFileByServerRelativeUrl(serverRelativeUrl);

var limitedWebPartManager = oFile.getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared);

var Templete = '/sites/05876/TPPEGDevelopment/SiteAssets/Test.html';

var ContentTitle = projectName;

var webPartXml = '<?xml version=\"1.0\" encoding=\"utf-8\"?>' +
      '<WebPart xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"' +

        ' xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"' +

        ' xmlns=\"http://schemas.microsoft.com/WebPart/v2\">' +

        '<FrameType>Default</FrameType><Title>' + ContentTitle + '</Title>' +
        '<Description>Use for formatted text, tables, and images.</Description>' +


        '<IsIncluded>true</IsIncluded><ZoneID></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 /><HelpLink />' +


        '<HelpMode>Modeless</HelpMode><Dir>Default</Dir><PartImageSmall />' +

        '<MissingAssembly>Cannot import this Web Part.</MissingAssembly>' +


        '<PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge><IsIncludedFilter />' +


        '<Assembly>Microsoft.SharePoint, Version=13.0.0.0, Culture=neutral, ' +


        'PublicKeyToken=94de0004b6e3fcc5</Assembly>' +


        '<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>' +


        '<ContentLink xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\" >' + Templete + '</ContentLink>' +


        '<PartStorage xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\" /></WebPart>';

    var oWebPartDefinition = limitedWebPartManager.importWebPart(webPartXml);

    var oWebPart = oWebPartDefinition.get_webPart();

    limitedWebPartManager.addWebPart(oWebPart, 'Left', 1);

    clientContext.load(oWebPart, 'Title');
    clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

0 个答案:

没有答案
相关问题