分类法字段是路径属性

时间:2013-11-04 11:37:17

标签: sharepoint sharepoint-2010 taxonomy

我想要做的只是显示我的分类法字段的完整路径....简单!

我已将这一小段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并保存字段时,一切正常!?!?!?!

我的问题是为什么我必须在部署后进入并保存字段才能应用此设置?

1 个答案:

答案 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();
        }
    }