Tuesday, September 19, 2017

Connect data in Web Parts

Connect data in Web Parts

You can use the menus and buttons in a SharePoint Web Part to create data connections without writing any custom code. For example, by connecting Web Parts, you can present alternate views of data from two Web Parts. In addition, you can perform related calculations between two Web Parts, or filter a Web Part by using values from another Web Part. You can use all these connections on one page. You can also create connections between Web Parts on different pages in the same top-level site by using a Web design program that is compatible with your site, such as SharePoint Designer.

In this article

Overview of Web Part connections

Create Web Part connections

Create or change a connection between two Web Parts

Complete your Web Part connection

Remove a connection between two Web Parts

Common kinds of Web Part connections

Master and details

Summary and details

Parent and child

Search and filter

Calculations

Alternative data views

Data enhancement

Overview of Web Part connections

By using Web Part connections, you can create or improve your site pages. You connect Web Parts so that when you perform an action in one Web Part, it changes the contents of another Web Part.

For example, you can connect an Employees List View Web Part to the Image Web Part by passing data between the two Web Parts. Each time that you select a row in the Employees List View Web Part that contains a column with a picture of that employee, you can see the picture displayed in the Image Web Part.

Basic Web Part connection

A Web Part connection is a way to pass data from one Web Part to another Web Part and synchronize their behavior.

One Web Part provides the data.

Data can be lists, rows, cells, or parameter values.

The other Web Part gets the data.

You can create a Web Part connection from either Web Part by using the connection type menu from the Connections command on the Web Part menu.

Note:  You can create connections only between Web Parts that are on the same page. To connect a Web Part to data from another site or data source, you add a data view by using a Web design program such as SharePoint Designer.

For example, a menu command from one Web Part connection type might show Provide Row To, and the menu command from the target Web Part connection type might show Get Row From. The following table describes common commands that you might see on a Connections menu.

Command on the Connections menu

Description

Send Row of Data To

You can connect the List View Web Part to another Web Part by passing a selected row of data to the other Web Part.

In standard view, a Select Item column is automatically added when you connect the List View Web Part. It contains options that enable you to indicate which row to pass to the other Web Part. You can select only one row at a time in standard view. Some columns, such as the Edit column, are not available for use in a Web Part connection.

In datasheet view, you can select multiple rows, but only one row is passed to the other Web Part. If multiple rows are selected, the row that contains the active cell is passed to the other Web Part, and all other rows are ignored. You cannot provide data in the Total row or New row to the other Web Part.

With this kind of connection, you can have more than one Web Part connected to the List View Web Part.

Get Parameter Values From

This option applies the parameters from one column in the provider Web Part to a column in the consumer Web Part.

Get Filter Values From

In standard and datasheet view, you can connect the List View Web Part to another Web Part that can provide the following information to it:

  • One or more column name and value pairs of data that filter data in the List View Web Part

  • A column of data to sort data by either ascending or descending order in the List View Web Part

With this kind of connection, only one other Web Part can be connected to the List View Web Part.

You can also create connections between Web Parts on two different Web Part Pages by using a Web design program such as SharePoint Designer.

Top of Page

Create Web Part connections

Before you attempt to create a connection between Web Parts, you should complete the following three steps.

Step 1: Decide what data that you want available on the page   
Often, there are one or more lists on a site that provide the data that you want. Lists present your data in a tabular format. They make it easier to modify and refresh data, change the sort order, filter within the list, and aggregate data. You can create a view that displays only the select data in the format that you want. By using the view selector in the tool pane, you can change the view of a List View Web Part, to work with just the columns that you want. To create a view, from the list, in the Ribbon under List Tools, click List, click Create View, select the view format that you want, and then select the data that you want to display.

Step 2: Add List View Web Parts to page   
You can add a list to a page by adding it as a Web Part to the page.

Step 3: Connect the Web Parts to get the results that you want   
You can create connections only between Web Parts that support Web Part connections. Web Parts that support Web Part connections include the List View Web Part, Form Web Part, and Image Web Part.

The Connections menu on the Web Part menu displays only the kind of connection that you can create, and the available Web Parts menu displays only compatible Web Parts. After you complete steps 1 and 2, you can make the Web Part connection without using scripting or coding.

Top of Page

Create or change a connection between two Web Parts

By using menus and dialog boxes, you can connect Web Parts, pass data between them, and synchronize their behavior.

  1. Browse to the page that contains the two Web Parts you want to connect.

  2. On the Site Actions menu Button image , click Edit Page.

  3. From either one of the Web Parts, click the Web Part menu. Then, point to Connections, and point to the kind of connection that you want to create or change, such as Provide Row To or Get Sort/Filter From. Click the name of the Web Part for which you want to create or change a connection.

    Note:  The Web Part menu may not be enabled or visible on your page for several reasons. These reasons include a Web Part or a zone that does not support connections, an incompatible browser, or connections that are disabled on your

    site. The connection type submenu can vary from Web Part Page to Web Part Page and from Web Part to Web Part. This might occur because of differences among the property settings for the Web Part Page, Web Part, or Web Part zone, the compatibility of Web Parts on the page, or whether the Web Parts have compatible connection types.

For some Web Part connections, you might have to select additional information in the Configure Connection dialog box. For example, you might have to select the connection type that you want to use or a column that you want to filter. Also, depending on how one or both of the Web Parts were created, you may see additional dialog boxes that are unique to the Web Part connection.

Tip:  Tip You can hide a Web Part. For example, you might want to use it to provide data to another Web Part, but do not want it to display.

Note:  Only Web Parts that can be connected appear on the available Web Parts menu. Other Web Parts on the page might not support connections, or might not support connections to the current Web Part. In addition, your site might have limits on certain connection that are exceeded.

Top of Page

Complete your Web Part connection

When you establish an initial connection between Web Parts, the Configure Connection dialog box appears. From this dialog box, you can match columns between the Web Part that gets the data and the Web Part that provides the data.

Note:  You can make a connection that is correct, but not meaningful. For example, the Web Part that provides the data may have a product ID column and the Web Part that gets the data may have an employee ID column. Although you might be able to match these different ID values, the results will not make sense.

The following list provides some common examples of Web Part Connections:

Matching a row of data in one Web Part to a cell or field of data in another Web Part   
The Web Part that you are connecting from is a Contacts List View Web Part. One of the columns in the list view is a column that contains a hyperlink called Photo, which contains a URL to a picture of the contact. You connect to the Image Web Part, which can display only a URL that contains a picture. You have to select the Photo column from the Contacts Web Part to provide the correct match to the Image Web Part.

Matching a row of data in one Web Part to a column of data in another Web Part so that you can filter it   
The Web Part that you are connecting from is a List View Web Part that contains order data. One of the columns in the list view is a column that contains a line item called OrdersDetailsID. You connect to another List View Web Part that has several columns that contains order details. One of these is a matching column called OrdersDetailsID. To connect the two Web Parts so that when you select the order in one Web Part, it displays each line item for that order in the other Web Part. You must match the OrdersDetailsID columns in each Web Part.

Note: The column names do not have to be the same. However, the underlying data must match or have the same value.

Top of Page

Remove a connection between two Web Parts

  1. Open the page.

  2. On the Site Actions menu Button image , click Edit Page.

  3. Select one of the Web Parts from which you want to remove the connection.

  4. Click the Web Part menu, point to Connections, and then point to the type of connection that you want to remove, such as Provide Row To or Get Sort/Filter From.

  5. Then click the name of the Web Part from which you want to remove a connection.

    Note:  A check mark appears on the connections submenu for each selection that has a connection enabled. If you do not see a check mark, no connection is enabled.

  6. In the Configure Connection dialog box, click Remove Connection.

  7. When you are prompted to confirm that you want to remove the connection between Web Parts, click OK.

Common kinds of Web Part connections

There are many ways to combine and connect Web Parts on a page. You can create several of these Web Part connections on your page. The following scenarios describe common kinds of data connections between Web Parts.

Master and details

You have a master list of data and you have to display detailed information related to this master list.

Master and details example

  1. An Employee Basics Web Part contains basic, frequently accessed employee data, such as ID, name, and job title.

  2. To look up employee details, you select a row.

  3. The row is passed to the other Web Part.

  4. In the Employee Details Web Part, all the employee details are displayed in a form.

In a List View Web Part, you can even sort and filter a large list to help find the employee before you select the row. If the detail data is extensive, you can even display the Employee Details Web Part on another page.

Top of Page

Summary and details

You have a summary list of data and you have to display the detailed information that produces the summary data.

Summary and details example

  1. A Year-to-Date Pay Stub Web Part contains your compensation information.

  2. You select the summary information about your accumulated vacation time and sick days.

  3. The summary information is passed to the other Web Part.

  4. In the Pay Stub Details Web Part that displays weekly data, you verify the data that you see recorded.

Top of Page

Parent and child

You display a list of data (the parent), and for each row there is one or more related rows (the children) that you want to display in another list.

Parent and child example

  1. An Orders Web Part provides a list of the most recent customer orders.

  2. You click the row that contains the order that you want to examine.

  3. The row is passed to the other Web Part.

  4. In the Order Details Web Part, all the line items for that order are displayed.

Top of Page

Search and filter

You want to enter data, such as search or filter criteria, in one Web Part to display the results in another Web Part.

Search and filter example

  1. In the Book Search Web Part, you enter the book information, such as title, author, and subject, to try to find the book or set of books.

  2. You click SUBMIT.

  3. The search criteria are passed to the other Web Part.

  4. The Book List Web Part displays one or more books that match your search criteria.

Top of Page

Calculations

Although you can often calculate data inside a Web Part, sometimes you may want to combine two Web Parts to make your calculations more flexible.

Calculations example

  1. You enter mortgage numbers into a Mortgage Numbers Web Part.

  2. You click GO.

  3. The mortgage numbers are passed to the other Web Part.

  4. The Mortgage Calculator Web Part computes the mortgage and displays the monthly payment schedule.

Top of Page

Alternative data views

Viewing your data in several different ways can help you understand implications, trends, and relationships. You can pass lists, rows, and cells (or fields and parameters) from one Web Part and display the data in an alternative view.

An alternative view of a list

You want to display all company employees in a hierarchy chart.

Alternate view of list data

  1. The Employees Web Part displays the employee ID, employee name, job title, and manager ID of everyone who works for your company.

  2. Because you use all the data, no selection is required.

  3. All the data is passed to another Web Part.

  4. The Organization Chart Web Part displays the working relationships between employees and can display alternate views of this hierarchy.

    An alternative view of a row

You want to view a row of demographic data in a chart, such as a pie chart or bar graph.

Alternate view of row data

  1. A Population Statistics Web Part displays demographic data such as age, income, and heritage.

  2. You select a row of demographic data.

  3. You pass the data to another Web Part.

  4. The Chart Web Part displays the row of data in a pie chart and alternatively a bar graph.

    An alternative view of a cell

You want to track the overall progress of a fund-raising drive.

Alternate view of cell data

  1. In a Fund-Raising Web Part, each member of a group enters how much money he or she raised.

  2. The current total is displayed in a total field.

  3. The total field is passed to the other Web Part.

  4. You check your group's overall progress in the Charity Goal Web Part.

Top of Page

Data enhancement

You want to augment basic data about people and places to make it more interesting, appealing, and useful.

Data enhancement example

  1. A Contacts Web Part displays information that you must have to keep track of business associates, such as name, address, and perhaps a photo.

  2. You select a contact.

  3. A row of data is passed to the other Web Part.

  4. You see a photo of the contact displayed in the Image Web Part and then locate the contact's business address in a Map Web Part.

Top of Page

No comments:

Post a Comment