Tuesday, March 22, 2011

Conditional formatting in a SharePoint 2007 list view

I have just set up a new SharePoint 2007 team site to help me managing my new project documents. I have the following list where I record all mandatory documents for my project and check if the document has been produced or not.


I wanted to find a simple solution to colour code each line of the list view, to display green background for documents that exists (Done == ‘Yes’) and red colour to non-existing documents (Done == ‘No’).

Here is how to proceed:

First let’s create a new view. Click on the View drop down list and select Create View.


Select Standard View from the list of available type of view.


And create a new view that display Attachments if any, Document Name and the "Done" flag.


Once created, open Microsoft Office SharePoint Designer 2007 to edit this view. First open the site and then select the .aspx page that corresponds to the view.



Right click on the List View Web Part and select Convert to XSL Data View. This will convert settings for the current view into data view parameters.


Once converted, right click on the web part and select Conditional Formatting.

  
We are now ready to add new formatting conditions. On the Conditional Formatting Tool box, click on Create and choose Apply formatting


The condition criteria window opens; you can now enter your conditions. Click on Click here to add a new clause…
Enter criteria. In our example, if the field Done == ’Yes’ then we modify the style to display green background.



Do it for the second formatting condition, if the field Done == ’No’ then we modify the style to display red background.



To complete this example, we can also add a data sorting property to our view. Click on Data View and select Sort and Group…


And sort by Document Name ascending order.


Save your changes.


And here is the result.


It remains some comments so that this view could be perfectJ, I still not have time yet to fix those issues.
First issue: If I try to add this view as a web part on my site Home page, I get the following error:
Cannot save the property settings for this web part. Cannot complete this action. Please try again.

Second “issue”: When you mouse over an item, it is displayed with default background, which can be fixed probably


Last comment: The modified view can now be only edited using Microsoft Office SharePoint Designer 2007.

Thursday, March 17, 2011

SharePoint Feature Stapling

I just discover while working on the SharePoint 2010 MCPD certification, what is Feature Stapling.
Feature Stapling allows you to create a feature and then associate it with any site definition without ever touching the site definition files themselves. Your feature will be executed when the site is being provisioned.

The full article can be read on sharepointmagazine.net.