• Aucun résultat trouvé

Customizing Data Views

Dans le document Microsoft SharePoint Designer 2010 (Page 186-189)

Data Views provide virtually limitless possibilities for formatting data . Like the XLV Web Part, Data Views do not contain data; they point to data stored elsewhere . When you request a page, SharePoint queries the SQL Server content database for the proper-ties of the Data View to find the location of the data . Then the Data Retrieval Service obtains the data as XML, and SharePoint dynamically transforms the data to HTML as defined in the XSLT in the Data View . SharePoint Designer displays the returned XML data in the Data Source Details task pane and in Design view . You can use Design view as a visual XSLT editor, so you can manipulate the XML data in the Data View Web Part by using the same editing techniques that you used for editing static HTML in Chapter 4,

“Customizing a Web Page .” As you format the data in one of the HTML cells, the effect cascades to other cells within the same column .

Note The Data Retrieval Service can be configured on a Web-application-by-Web-application basis using the SharePoint 2010 Central Administration Web site. To see this site, on the Application Management page, under Databases, click Configure The Data Retrieval Service.

You can modify the DFWP in many of the same ways that you can modify the XLV Web Part, such as specifying which fields to display; filtering, sorting, and grouping data items; displaying data items in sets; or limiting the number of items that are displayed . You cannot, however, use Datasheet view for DFWPs .

Using the Data View Preview command on the Display tab, you can modify the No Matching Items template . This allows you to change the text displayed when no items are displayed in your Data View or XLV Web Part .

In this exercise, you sort and group the data displayed in a Data View, amend the text, and modify the functions used when grouping the data .

SET UP Using SharePoint Designer, open the site you used in the previous exercise if it is not already open, and then open CreateDVWP.aspx in edit mode with the SalesReport DFWP selected.

1.

In the field heading row, right-click ListPrice, and then click List Price .

2.

On the Data View Tools, Options tab, click Sort & Group in the Filter, Sort &

Group group .

The Sort And Group dialog box opens .

3.

In the Available fields list, scroll down, click Sales Person, and click Add . Under Group Properties, click Show group header, and then click Show group footer .

Sor & Group

4.

Click Advanced Grouping . In the Advanced Grouping dialog box, select Show column totals per group .

5.

Click OK to close the Advanced Grouping dialog box .

Tip The Show Column Totals Per Group option in the Advanced Grouping dialog box does not allow you to select which group or columns to total. It creates a formula for each column that it detects is numeric. Once the formula is created, delete those group totals or column totals that are not required or do not make business sense.

6.

In the Available fields list, click Quarter, and click Add . Under Group Properties, click Show group footer and Show group header.

7.

In the Available fields list, click Customer, and then click Add .

8.

Click OK . The Sort and Group dialog box closes .

The CreateDVWP .aspx page refreshes, and the DVWP displays the data from the SalesReports list grouped by sales person and then by quarter . The data is ordered by customer . Totals for the Quantity Purchased, List Price, and Total Purchased col-umns are displayed per quarter and per salesperson .

Note The group footer count for sales person is correct, but the quarter count is inaccurate. The count for that group is using only the field Quarter, but to get an accurate count, the Sales Person and Quarter fields should be used to create the group.

The NaN (Not a Number) entry for the List Price and Total Purchased fields occurs because the values in those fields contain nonnumeric characters—the dollar sign ($) and commas. You will correct these issues later in this chapter.

9.

Double-click the first occurrence of Count, and type No. of sales in Quarter . The text change cascades to all group-by-quarter counts .

10.

Double-click Count before the next Sales Person listed, and type Sales per Year . The text change cascades to all group-by-sales-person counts .

11.

Double-click sum to the left of 1237, and type max . Then click 1237, click the smart icon that appears, and select Max .

The value in the Quantity Purchased column contains the maximum quantity pur-chased in one sale .

12.

On the Design tab, under Data View Preview, click Default Preview in the Preview group, and select ‘No Matching Items’ Template .

The page refreshes . No content is displayed .

13.

Select There are no items to show in this view of the “SalesReport” list, and type The sales reports for this period are not available .

14.

On the Design tab, under Data View Preview, click No Matching in the Preview group, and select Default Preview .

CLEAN UP Save CreateDVWP.aspx, and then click Yes to reload the page to see the results of saving it. Leave SharePoint Designer open if you are continuing to the next exercise.

Dans le document Microsoft SharePoint Designer 2010 (Page 186-189)