Thursday, October 4, 2012

Related List /Items View in SharePoint 2010

SharePoint 2010 has an enhancment to show related list views. There is pre-requisite to make it work. You should have lists with relation established using lookup columns.

Let's try it.

1. Create a custom list named "Country". We will use "Title" column. If you want to add any new columns, you can do so.

2. Create one more list named "City". Create the columns as shown below. The "Country" must be a lookup column to "Country" list.

3. Add some city information to the list.

4. Right-click on any city and click "Open in New tab/Window". This way it will launch the display form in browser window. This will make "Site Actions" menu available. The "Site Actions" menu is not available in dialog. Click "Site Actions" -> Edit Page.

Click inside the existing web part zone. The ribbon starts presenting "Page Tools" tab. It has a button "Related List". Click it. It shows the all related list. In our case, it is city.

5. Click on the related List "City". It added a related items view as shown below. It will only show cities for the selected country. i.e. the country for which display form is shown.

6. Do not forget to click "Stop Editing" in the "Page" tab of ribbon. This actually saves the page with changes.

7. User can add items to the related list using related items web part. Click the "Add new item" link and it starts showing add new item form page for the "City" list. You can add item here. If the Country display form (View Properties) is being preseneted for "India", still you can add item for "Japan" from this screen. Be careful.


8. You can change the view of related list items. You can add/ remove column from the view using "Edit the current view" link or selected the appropriate view from the drop-down.

9. Edit the current view, after saving view changes takes back to the display form which will show nothing. So close the browser tab/window and reopen. You can see the changes.

Using SPD 2010:

1. Create a new view "DetailedView" for Country list. The view must be same as All Items view.
2. Check-out the page in SharePoint Designer 2010. To accomplish this, open the list using All Files option in SPD 2010.
3. Right-click the page and click on "Edit in Advanced mode".
4. In "Design" view, click inside the available web part zone. Put the cursor at a location where you want to add the related list items web part.
5. Click "Insert" tab in ribbon and it has a button called "Related Item View". This button presents all related lists as shown below.

6. Click the "City:Country" and it adds the related items view on the page as below. Save the page and check -in
7. The view page on browser refresh starts showing a new column as shown below to select an item and the related items are shown for the selected item. Selected item has dark black arrow icon.
 


I will suggest to use browser based method as it will avoid the un-ghosting of the page. But if you would like to customize the XSL of related items web part, better to use SharePoint Designer.
Post a Comment