SPFieldLinkCollection.Reorder 出现问题:未按记录工作
我正在使用在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在我的字段名称上。
我有两个查找,是我在事件处理程序执行之前以编程方式创建的。这些查找的内部名称与我在 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.