An XSLT dataview is a great way to modify the look and feel of displayed data in a sharepoint site. The dataview web part is able to display data from either sharepoint lists, or from external data sources.
This article will focus on how to create a simple xslt dataview for a sharepoint list.
First we will create a sharepoint list - Contacts, and fill it with some sample data:
Now, lets create a new page that we will use to create the xslt dataview in:
Open the page in SharePoint Designer (see my previous article if you forgot how - you will need to detach it from the page layout first!).
Now we can add the contacts list to the page using sharepoing designer. You can also do that from the browser before opening the page in sharepoint designer if you prefer:
Let us work in a clean environment - change the properties of the web part so it doesn't display the toolbar. Annoyingly, in sharepoint designer this means you have to open the dropdown menu for the web part (looks like a list icon) and select "change layout":
Select not to show a toolbar.
Now we can transform the web part to an XSLT dataview. Just right-click the web part and choose "convert to xslt data view":
The page should flash and then the web part will appear again, only slightly different. A new menu will appear with a lot more options (filter, sort and group, paging, edit columns, change layout, data view preview, show with sample data, conditional formatting, web part connections, parameters, refresh dataview, dataview properties).
Now you can start playing with it!
In this article I will not go over all the options - I will just conclude by showing you the conditional formatting, and how to deploy the web part to another page in the site:
Click on "Conditional Formatting" in the common data view tasks menu:
The task pane on the right should change to the "Conditional Formatting" pane. Now we can click a row (any will do), and then click the "create" menu, and choose "apply formatting" from the menu:
Because we selected a row, we can apply formatting to that row based on rules we will now define in this screen:
In this example I chose the rule - when first name is "Ishai". Press OK to get to the formatting options:
I set the formatting to show my contact's row with a light blue background, in bold and in uppercase.
Save the file, and view it in the browser:
As you can see - it shows exactly what I wanted it. Now to deploy it to the home page of the site (which we didnt want to detach from the layout page):
In the browser, open the actions menu for the web part and click "export":
Now save the file to your desktop, and go to the homepage of the site. Switch to "edit page mode", click on "add a web part" in one of the zones, and then on the "advanced web part gallery and options" link at the bottom.
Use the dropdown at the top of the pane to switch to web part import pane:
Now, browse to the saved file and click the "upload" button. The web part should appear as an option in the pane. Drag and drop it to the zone you want it in:
And now you can click on "Exit Edit Mode" and see your wonderful new home page, that is still attached to it's layout page!
The next article will show how to do the same, but with external data!