将现有网站栏添加到自定义列表

发布于 2024-08-28 23:32:33 字数 143 浏览 2 评论 0原文

我想我快要疯了——这看起来很容易做到,但我根本找不到任何相关信息。

我创建了一个自定义列表并向其中添加了 4 列。创建者和修改者已在列表中,但在视图中隐藏。

我想向此自定义列表添加“修改日期”列(这是内置字段)。我如何以编程方式执行此操作?

I think I'm going mad - this seemed like an easy thing to do but I can't find any info on it at all.

I have created a Custom List and added 4 columns to it. Created By and Modified By are already in the list but hidden from the view.

I want to add a Date Modified column (which is a built in field) to this Custom List. How do I do this programmatically?

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

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

发布评论

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

评论(2

夜吻♂芭芘 2024-09-04 23:32:33

您是否正在尝试将该列添加到列表或视图中?默认情况下,“修改日期”列应添加到列表中。要将其添加到视图中(即,当您导航到列表时它会显示),您可以使用类似于以下的代码:

using (SPWeb web = new SPSite("http://intranet/").OpenWeb())
{
    SPList customList = web.Lists["CustomList"];
    SPView defaultView = customList.DefaultView;

    defaultView.ViewFields.Add("Modified");
    defaultView.Update();
}

Are you trying to add the column to the list or to a view? The Date Modified column should be added to the list by default. To add it to the view (i.e. so it shows up when you navigate to the list) you can use code similar to the following:

using (SPWeb web = new SPSite("http://intranet/").OpenWeb())
{
    SPList customList = web.Lists["CustomList"];
    SPView defaultView = customList.DefaultView;

    defaultView.ViewFields.Add("Modified");
    defaultView.Update();
}
一念一轮回 2024-09-04 23:32:33

使用共享点,有时你必须做一些丑陋的事情……你不希望你的孩子长大后知道的事情。

这是一个可怜的解决方案:
- 您可以像其他任何字段一样创建日期时间字段。
- 当数据更改时,您创建一个工作流程,工作流程启动,更新您的自定义修改字段,然后停止。

无论如何,我知道可以显示默认的“修改”字段,也许您想朝这个方向多走一点。

With sharepoint sometimes you must do ugly things... stuff you would not want your children know when they grow up.

Here is a pitifull solution:
- you create a DateTime field just like any other.
- you create a workflow when data changes, workflow starts, updates that your custom modified field and then stops.

ANYWAY, I know it is possible to show the default Modified field, perhaps you wanna go in that direction a little bit more.

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