How to deploy conditional formatting in a SharePoint 2010 list definition using Visual Studio 2010
Posted by Ingo Karstein on 2011/05/09
This time it’s not a walkthrough. Only a description of what you have to do. – It’s “experimental”!!!
The need is to deploy a conditional formatting in a list definition that was created in a SharePoint 2010 Visual Studio (2010) project.
1. You need to design the list definition. Create a list instance for the list definition. This instance you can remove later if you want.
2. Deploy the project. It’s without conditional formatting at this point.
3. Create the conditional formatting in SharePoint Designer.
Open the list instance.
Open the list view you want to modify.
Select the cells that should have a conditional formatting.
Create the conditional formatting.
4. Open the “Code” view of the list view page.
5. Look for the “<xsl>” tag of the XsltListViewWebPart that renders the list data.
Copy the content of the <xsl> tag.
6. In Visual Studio open the “Schema.xml” file of the list definition.
7. In the <views> tag look for the view you want to modify. E.g. “AllItems.aspx”. Look for the “Url” attribute of the view tag that contains the Web Part Page name (e.g. “AllItems.aspx”).
8. Before the closing “view” tag add this:
<Xsl> <![CDATA[ ... ]]> </Xsl>
Replace the “…” through the copied content of the web part pages “xsl” tag content.
9. Deploy the project.
10. It’s done! – BUT: You may be unable to edit the conditional formatting in SharePoint Designer! As I said: It’s experimental.