我想要做的只是显示我的分类法字段的完整路径....简单!
我已将这一小段XML添加到我想要将此属性应用到的字段中的<ArrayOfProperty>
。
<Property>
<Name>IsPathRendered</Name>
<Value xmlns:q7="http://www.w3.org/2001/XMLSchema" p4:type="q7:boolean" xmlns:p4="http://www.w3.org/2001/XMLSchema-instance">true</Value>
</Property>
该字段的所有设置似乎都已应用,我已通过GUI和SharePoint管理员进行了检查,似乎已应用!
然而,并没有显示完整的路径......
当我进入GUI并保存字段时,一切正常!?!?!?!
我的问题是为什么我必须在部署后进入并保存字段才能应用此设置?
答案 0 :(得分:1)
虽然我也想知道如何在XML中执行此操作,但还有一种方法:您可以通过在IsPathRendered
实例上设置TaxonomyField
属性来在功能接收器中处理它。
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPSite site = (SPSite)properties.Feature.Parent)
{
Guid fieldId = new Guid("{YOUR-FIELD'S-GUID-GOES-HERE}");
TaxonomyField field = site.RootWeb.Fields[fieldId] as TaxonomyField;
// Render full taxonomy path, not just the leaf.
field.IsPathRendered = true;
field.Update();
}
}