SP.WebParts.LimitedWebPartManager.addWebPart Method (sp.js)

Adds a Web Part to the Web Part Page.

Applies to: apps for SharePoint | SharePoint Foundation 2013 | SharePoint Server 2013

SP.WebParts.LimitedWebPartManager.addWebPart(webPart, zoneId, zoneIndex)

Return value

Returns a SP.WebParts.WebPartDefinition instance representing the position at which the Web Part will be inserted within the Web Part zone.

Remarks

When Scope is User, the current user must have permissions to add and delete personalized Web Parts. When Scope is Shared, the current user must have permissions to customize pages. Use importWebPart to import a Web Part, and then use addWebPart to add it to the Web Part Page. Each Web Part zone must have a unique name. It must not be null. It must not be empty. Its length must be equal to or less than 64.

The new Web Part must be inserted directly before the existing Web Part with the lowest Web Part zone index greater than or equal to zoneIndex. If zoneIndex is greater than the index of all Web Parts in the zone or there are no Web Parts in the Web Part zone, then the new Web Part must be inserted at the end of the Web Part zone. Its value must be equal to or greater than 0.

Parameters

  • webPart
    The Web Part to add to the Web Part Page.

  • zoneId
    The name of the Web Part zone to which to add the Web Part.

  • zoneIndex
    A Web Part zone index that specifies the position at which the Web Part will be inserted within the Web Part zone.