Create XSLT List View Web Parts using SharePoint Designer
2010
In this exercise you create an XSLT List View Web Part
within Microsoft SharePoint Designer 2010 that displays a list of employees on
the Home page of local Web site. To complete this task, you must do the
following:
Create a Visual
Web Part in SharePoint Designer 2010
In this task,
create a Visual Web Part in Microsoft SharePoint Designer 2010.
To create the
visual Web Part
- Start SharePoint Designer 2010 by clicking Start Menu, then click All Programs, click Microsoft Office, and then click Microsoft SharePoint Designer 2010.
- Click the Open Site button and in the Open Site dialog window, type the URL of the local Web site (such as http://localhost/SampleWebPartSite) in the Site Name box.
- From the SharePoint Site left navigation pane, click the Site Pages tab, and then click Home.aspx.
- On the ribbon menu, click Edit File, and then click Edit File in Advanced Mode. Ignore any errors that you may see on this screen by clicking OK.
- On the Home view tab, click Code at the bottom of the designer pane to show the code view.
- In the code screen, scroll to the bottom of the page and place the pointer before the </ContentTemplate> end tag (after the </WebPartPages:WebPartZone> closing tag) as shown in Figure 1.
- Click the Insert tab on the ribbon, and then click Data View.
- In the drop-down list, click Employees. The SharePoint Designer adds the XsltListViewWebPart Web Part to the Home page.
- Click Save at the top of the page. If you are prompted for confirmation, click Yes.
- Open the browser to the Web site that you specified earlier. At the bottom of the Home page, you should see the XsltListViewWebPart Web Part as shown in Figure 2.
Modify the XSLT
List View Web Part
In this task,
modify the Web Part to add formatting and to limit the number of items
displayed.
To modify XSLT
List View Web Part
- Return to SharePoint Designer 2010and in the design view (click Design at the bottom of the screen), click the table cell that contains the word Title.
- In the Apply Styles window on the lower right of the screen, in the Select CSS style to apply pane, scroll down in the Select CSS style to apply pane and then click .ms-bodyareapagemargin. Right-click and then click Apply Style as shown in Figure 3. If the Apply Styles window is not displayed, on the View tab, click Apply Styles under the Task Panes button.
- In the code view of the designer (click Code at the bottom of the screen), scroll up to RowLimit and change the value to 5.
- In the code view of the designer, scroll up to WebPartPages:XsltListViewWebPart and type the ChromeType attribute, and then select TitleAndBorder as the chrome type as shown in Figure 4.
- Click Save at the top of the page.
No comments:
Post a Comment