SPFieldLinkCollection.Reorder 出现问题:未按记录工作

发布于 2024-08-13 04:44:02 字数 798 浏览 7 评论 0原文

我正在使用在 SharePoint 中构建的自定义列表。我有一个功能,它有一个事件处理程序,当该功能被激活时,该事件处理程序就会启动。该事件处理程序调用(我可以调试并观察它执行)以下函数:

我希望该函数的行为如此处所述。

private void OrderFields(SPWeb web)
{
   // This works fine: I get the expected SPContentType object
   // There is only 1 SPContentType in ContentTypes
   SPContentType contentType = web.Lists[TASK_LIST_NAME].ContentTypes[0];

   contentType.FieldLinks.Reorder(new string[4]
   {
      "Field1",
      "Field2",
      "Field3",
      "Field4"
   });

   contentType.Update();
}

调用 OrderFields 的函数也会调用 web.Update();

不幸的是,重新排序调用不会对表单上的字段进行重新排序。我错过了什么吗?谁能建议我可以尝试的任何技巧?

I am working with a custom list I've built in SharePoint. I have a feature which has an event handler that kicks off when the feature is activated. That event handler calls (I can debug and watch it execute) the following function:

I'm intending that the function behaves as described here.

private void OrderFields(SPWeb web)
{
   // This works fine: I get the expected SPContentType object
   // There is only 1 SPContentType in ContentTypes
   SPContentType contentType = web.Lists[TASK_LIST_NAME].ContentTypes[0];

   contentType.FieldLinks.Reorder(new string[4]
   {
      "Field1",
      "Field2",
      "Field3",
      "Field4"
   });

   contentType.Update();
}

The function that calls OrderFields calls web.Update(); as well.

Unfortunately, the reorder call does not reorder my fields on my form. Am I missing something? Can anyone suggest any tricks I might try?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酷到爆炸 2024-08-20 04:44:02

问题出在我的字段名称上。

我有两个查找,是我在事件处理程序执行之前以编程方式创建的。这些查找的内部名称与我在 CAML 定义的 Name 和 StaticName 参数中指定的“Field1”和“Field2”名称有很大不同。

相反,内部名称似乎由显示名称、替换为“0020”的空格组成,并被截断为 32 个字符的长度。

The problem was with my field names.

I had two lookups that I'd programmatically created earlier in the execution of the event handler. These lookups' internal names vary significantly from the "Field1" and "Field2" names I'd given them in the Name and StaticName parameters of my CAML definition.

Instead, the internal name seems to be composed of the Display Name, spaces replaced by "0020", and truncated to a length of 32 characters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文