list 在 SharePoint 列表中表示父子关系

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/306639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 01:18:36  来源:igfitidea点击:

Representing parent-child relationships in SharePoint lists

sharepointlistparent-childrelationship

提问by Chris Farmer

I need to create some functionality in our SharePoint app that populates a list or lists with some simple hierarchical data. Each parent record will represent a "submission" and each child record will be a "submission item." There's a 1-to-n relationship between submissions and submission items. Is this practical to do in SharePoint? The only types of list relationships I've done so far are lookup columns, but this seems a bit different. Also, once such a list relationship is established, then what's the best way to create views on this kind of data. I'm almost convinced that it'd be easier just to write this stuff to an external database, but I'd like to give SharePoint a shot in order to take advantage of the automated search capabilities.

我需要在我们的 SharePoint 应用程序中创建一些功能,以使用一些简单的分层数据填充一个或多个列表。每个父记录将代表一个“提交”,每个子记录将代表一个“提交项目”。提交和提交项目之间存在 1 对 n 的关系。这在 SharePoint 中可行吗?到目前为止,我所做的唯一列表关系类型是查找列,但这似乎有点不同。此外,一旦建立了这样的列表关系,那么在此类数据上创建视图的最佳方法是什么。我几乎确信将这些内容写入外部数据库会更容易,但我想尝试一下 SharePoint,以便利用自动搜索功能。

回答by Michael Stum

ProperParent/Child in Sharepoint is near impossible without developing it yourself. There is one approach to that here: Simulate Parent / Child relationship in SharePoint 2007 with Folders & Content Types

如果不自己开发,Sharepoint 中的正确父/子几乎是不可能的。这里有一种方法:使用文件夹和内容类型模拟 SharePoint 2007 中的父/子关系

(Note: This concerns SharePoint 2007. In 2010, Joins make this much easier)

(注意:这与 SharePoint 2007 相关。在 2010 年,联接使这变得更加容易

回答by Nat

Do it in a separate database, create a page(s) with controls that surfaces the data and run search over that. Loses quite a bit of the SharePoint features though.

在单独的数据库中执行此操作,创建一个页面,其中包含显示数据的控件并对其运行搜索。虽然失去了很多 SharePoint 功能。

Otherwise it may be okay to create a custom field control that will allow you to lookup the data in the other list. The custom field control can be the one to "view" the related data. I know we have done it for parent child relationships between pages on the same list. Not 1-to-N though.

否则,可以创建一个自定义字段控件,允许您在另一个列表中查找数据。自定义字段控件可以是“查看”相关数据的控件。我知道我们已经为同一列表中的页面之间的父子关系做了它。虽然不是 1 对 N。

Tough choice either way.

无论哪种方式都是艰难的选择。

回答by salgo60

My vote is "to write this stuff to an external database"

我的投票是“将这些东西写入外部数据库”

You miss a lot of things in Sharepoint things like transaction support, referential integrity, easy way of updating (compare SQL), reporting (using Reporting Services and a SQL database)... see sharepoint as a way to store documents and simple lists.....

您错过了 Sharepoint 中的很多东西,例如事务支持、参照完整性、简单的更新方式(比较 SQL)、报告(使用 Reporting Services 和 SQL 数据库)……将 sharepoint 视为一种存储文档和简单列表的方式。 ....

The argument for Sharepoint is if it is a small application, no requirements on support for transactions, no need to import external data etc...

Sharepoint的论点是如果它是一个小应用程序,不需要支持交易,不需要导入外部数据等......

When people say Sharepoint is a development plattform there is a need to define whjat they think a development plattform is.

当人们说 Sharepoint 是一个开发平台时,需要定义他们认为开发平台是什么。

The latest rumours about Sharepoint 2010 tells us that there will be support for SQL server based lists in next version ..... which I think will at least move Sharepoint in the right direction ....

关于 Sharepoint 2010 的最新传言告诉我们,下一版本将支持基于 SQL 服务器的列表......我认为这至少会使 Sharepoint 朝着正确的方向发展......

回答by salgo60

Take a look at SLAM, SharePoint List Association Manager, an open source project my company created and actively supports. SLAM allows you to synchronize SharePoint data to SQL, including any relationships between lists. SLAM, in addition to being very useful on its own, is really a framework intended to allow developers to create their own complex data associations using what we call SLAM type profiles. We have one out-of-the-box type profile which is part of the open source project which actually allows you to make a SharePoint list hierarchical using the nested set model. For more information, see this pageon our codeplex site.

看看 SLAM,SharePoint 列表关联管理器,这是我公司创建并积极支持的一个开源项目。SLAM 允许您将 SharePoint 数据同步到 SQL,包括列表之间的任何关系。SLAM 除了本身非常有用之外,它还是一个真正的框架,旨在允许开发人员使用我们称为 SLAM 类型配置文件来创建他们自己的复杂数据关联。我们有一个开箱即用的类型配置文件,它是开源项目的一部分,它实际上允许您使用嵌套集模型使 SharePoint 列表分层。有关更多信息,请参阅我们的 codeplex 站点上的此页面

回答by salgo60

I do this a lot just using sharepoint, using a framework called AAA (Activity,Assignment,Artifact), which allows you to use lookup columns to link an assignment or artifact to a parent Activity. You then build a web part page with connected web parts that allow you to filter all assignments and artifacts by activity. For example, click next to a submission in the submission web part, and all of the submission items attached to that submission will show up. Works great.

我经常使用 sharepoint,使用称为 AAA(Activity、Assignment、Artifact)的框架来执行此操作,该框架允许您使用查找列将作业或工件链接到父 Activity。然后构建一个带有连接的 Web 部件的 Web 部件页面,允许您按活动过滤所有分配和工件。例如,单击提交 Web 部件中提交的旁边,将显示附加到该提交的所有提交项目。效果很好。

回答by Daniel McPherson

The other approach that you can look at using is persisting XML with a field in the item. This is the approach used by the Podcasting Kit (on CodePlex) to store things like ratings.

您可以考虑使用的另一种方法是使用项目中的字段持久化 XML。这是 Podcasting Kit(在 CodePlex 上)用来存储评分等内容的方法。

回答by EG.

One possible method is to create a submission content type based on the folder content type and a submission-item based on item content type. Then you can store data hierarchically like in file system and also will work default views and search functionality.

一种可能的方法是创建基于文件夹内容类型的提交内容类型和基于项目内容类型的提交项目。然后您可以像在文件系统中一样分层存储数据,并且还可以使用默认视图和搜索功能。

Other way is to create lookup field that points to same list (list=”self”). This field will be used like reference to parent item and you will get list that contains recursively related data. To use this data programmatically will be ok but using views functionality will be little bit complex.

另一种方法是创建指向同一个列表的查找字段(list=”self”)。此字段将用作对父项的引用,您将获得包含递归相关数据的列表。以编程方式使用这些数据没问题,但使用视图功能会有点复杂。

回答by Andrew Lewis

It's easy to do using a connected web part.

使用连接的 Web 部件很容易做到。

Create two lists:

创建两个列表:

Parent (Id, Title) Child (Id, Title, ParentId)

父 (Id, Title) 子 (Id, Title, ParentId)

Create a new sharepoint page, add DataFormWebPart (displaying Parent) and another one for Child, set both of them to filter based on a QueryString parameter (use that Parameter to filter Parent.Id, and Child.ParentId) voila, you can display parent-child relationships. Now, adding children is more difficult, and that's the part I haven't worked out yet.

创建一个新的sharepoint页面,添加DataFormWebPart(显示Parent)和另一个用于Child,将它们设置为基于QueryString参数过滤(使用该参数过滤Parent.Id和Child.ParentId)瞧,您可以显示父-儿童关系。现在,添加孩子更困难,这是我还没有解决的部分。