基于行的动态列

发布于 2024-09-29 12:36:41 字数 625 浏览 2 评论 0原文

我正在做的事情可能真的很愚蠢,如果是这样,请纠正我,但我正在尝试做以下事情:

我想要一个包含(例如)以下项目的列表:

List Addresses

-Name
-Address
-City
-Country

但是,根据他们的国家/地区,我想要显示我想要在列表中记录的不同列。例如:

CountryColumns

(United States - SSN - Yes)
(United States - State - Yes)
(United States - Province - No)
(United Kingdom - SSN - No)
(United Kingdom - State - No)
(United Kingdom - Province - Yes)

然后当用户在国家列表中选择美国时,下次用户编辑其信息时,将显示某些列。 (也有可能全部显示,而下次带有“否”的列将被隐藏)。

我已经研究过执行此操作的方法,并且我只发现 Infopath 能够执行此操作。但是,这意味着我必须为每个国家/地区创建不同的视图,并显示/隐藏某些列。这似乎有点矫枉过正了。

有人知道如何做到这一点吗?

问候,

垫子

What I am doing might be really stupid, if so, please correct me, but I am trying to do the following thing:

I want to have a list with (for example) the following items:

List Addresses

-Name
-Address
-City
-Country

But, based on their Country, I want to display different columns that I want to record in a List. For instance:

CountryColumns

(United States - SSN - Yes)
(United States - State - Yes)
(United States - Province - No)
(United Kingdom - SSN - No)
(United Kingdom - State - No)
(United Kingdom - Province - Yes)

And then when the user picks United States in the country list, the next time the user edits his information, certain columns will be shown. (It's also possible that all will be shown, and that the next time the columns with No will be hidden).

I've looked at ways to do this, and I only found out that Infopath is able to do this. But, that'd mean I would have to create a different view for every country, and show / hide certain columns. It seems like that is a bit of overkill.

Anyone knows a way how to do this?

Greetings,

Mats

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

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

发布评论

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

评论(3

九厘米的零° 2024-10-06 12:36:41

以下是三个选项:

  1. 自定义内容类型。这可能是最符合 SharePoint 风格的方法。您可以为每个国家/地区创建一个内容类型,然后控制该内容类型中包含哪些字段。这样做的明显缺点是,您最终可能会创建很多内容类型,而且选择内容类型(尤其是创建新项目时)与从下拉列表中选择选项不同列表。
  2. JavaScript/jQuery。通过更改母版页或将内容编辑器 Web 部件添加到编辑表单,您可以使用 javascript 根据选定的国家/地区值隐藏某些字段。
  3. 自定义字段。这是最复杂的,但您可以创建一个继承自 SPFieldText,然后根据所选的国家/地区值管理其渲染可见性。

Here are three options:

  1. Custom content types. This is probably the most SharePoint-y way to do it. You can create a content type for each Country and then control which fields are included in that content type. The obvious downsides to this are that you could end up creating a lot of content types and also that selecting a content type (especially when creating a new item) is not the same as selecting a choice from a dropdown list.
  2. Javascript/jQuery. Either by changing your master page or by adding a Content Editor Web Part to your Edit Form, you could use javascript to hide certain fields based on the selected value of Country.
  3. Custom fields. This is the most involved, but instead of having the SSN field be a regular Single Line of Text field, you could create a custom field that inherits from SPFieldText and then manages its render visibility based on the selected value of Country.
吐个泡泡 2024-10-06 12:36:41

您可以通过四种方式修改 SharePoint 来实现此目的。

  1. 有一个列表地址内容类型,然后为每个需要额外字段的国家/地区提供单独的内容类型。使用 Web 部件使用正确的国家/地区内容类型将数据输入到列表中。

  2. 与上面相同,但您可以使用基地址内容类型将数据添加到列表中,而不是通过 Web 部件输入数据。使用项目添加事件接收器来决定将数据添加到哪种内容类型。

  3. 使用一种包含所有字段但具有自定义列表视图页面的超级内容类型来根据县值过滤字段。

  4. 将 infopath 与每个国家/地区的单独视图或每个特殊字段的一个部分结合使用,如果未选择所需的国家/地区,则将其隐藏。

我个人推荐4。它是最简单、最快实现的。

There are four ways you could modify SharePoint to do this that come to mind.

  1. Have a list address content type and then a separate content type for each country that requires extra fields. Use a webpart to enter data to the list using the correct country's content type.

  2. Same as above but instead of entering data through a web part, you can add the data into the list using the base address content type. Use an item adding event receiver to decide which content type to add the data to.

  3. Use one super content type that includes all fields but with custom list view pages to filter the fields based on the county value.

  4. Use infopath with either separate views for each country or a section for each special field with a condition to hide it if the required country isn't selected.

Personally I would recommend 4. It's the simplest and quickest to implement.

╄→承喏 2024-10-06 12:36:41

您无法开箱即用地执行此操作。

You cannot do this out of the box.

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