سؤال

كيفية الحصول على معرف منطقة جزء ويب عبر CSOM؟يحتوي WebPart على خاصية OneIndex ولكن لا يوجد يوم، بينما يحتوي WebPartDefinition على طريقة movewebpartto (سلسلة choxionid، int zoneindex) ولكن يفتقر إلى الطرق لاسترداد اللغة.

API من جانب الخادم لديه webpart.zoneid.

هل كانت مفيدة؟

المحلول

For those just finding this now, the current version (16.1) of the Microsoft SharePoint Online client object model now includes this property on the WebPartDefinition class.

http://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365

Note that this doesn't yet work on-prem, as the server side components don't yet expose this property.

نصائح أخرى

You can do it by yourself using standard JavaScript or jQuery.

I show you an example how to recognize Web Part Zone Id.

So if we have a page layout like this:

enter image description here

Then we will have a page like this:

enter image description here

That is how the DOM looks like:

enter image description here enter image description here

What I suppose is that the MSOZoneCell_ is a standard prefix then after that is the Zone Id. So you can use that on your method to move your web part around.

The REST API url needs to have the site url with full /sites/BusinessServices/ etc.

 https://TENANT/sites/HomePortal/_api/web/GetFileByServerRelativeUrl('/sites/HomePortal/Pages/ProductInfo.aspx')

And then need the personalizationscope when getting webparts :

 https://TENANT/sites/HomePortal/_api/web/GetFileByServerRelativeUrl('/sites/HomePortal/Pages/ProductInfo.aspx')/GetLimitedWebPartManager(1)

0 = Shared 1 = User

This works for me, using the SharePoint API.

var instance = SP.Ribbon.WebPartComponent.get_instance();
if (!instance.selectWebPartById(<id attribute from webpart element>) continue;
var zoneId = SP.Ribbon.WebPartComponent.get_activeWebPartZoneId();

Open the page for editing. Select the web part zone you want to know the ID for.

In the debug window, paste this:

var zoneId = SP.Ribbon.WebPartComponent.get_activeWebPartZoneId();

Thanks to Robbert Helling for getting me most of the way there

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top