1
votes

I am trying to figure out how to do something that I would think is commonplace, but I cannot find how to do. Given two Custom Lists, one with a field that is essentially a primary key, and the other with what is essentially a foreign key, I want to show all the rows from the first in one area of the display, and the related records for the selected row of the first, in a second part of the screen.

I am thinking this would be side–by–side web parts on a web-part page.

So:

 ID  pkID  Data             ID  fkID  Data
 ___________________        ______________________________
| 1   100  Row one. |      |  8   100  Related one/one    |
 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯       |  9   100  Related one/two    |
  2   113  Row two.        | 10   100  Related one/three  |
  3   118  Row n.           ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
                             11   113  Related two/one
                             12   113  Related two/two
                             13   118  Related n/one

(That is my attempt to show what is established between the two lists. Top row selected on the left, related records from the other row on the right.)

Surely this is common enough that there is a way to readily do this?

I suppose I might need to create a means of asserting that a row is 'selected.'

You will note that I am not useing the ID field that "belongs" to SharePoint.

1

1 Answers

0
votes

You can create look up fields to establish that relationship, sharepoint 2010 even allows you to enforce the relationship like in a SQL database. so for instace you can declare what happens if you try to delete a parent if there is childs (Cascade, Prevent, etc).

Have a read here:

http://office.microsoft.com/en-au/sharepoint-server-help/create-list-relationships-by-using-unique-and-lookup-columns-HA101729901.aspx

About visually displaying them, you might have to create some webparts for it, as the only support OOB is the link to the child entity from the main entity on the parent list.