Recently, I was working on a project that required the creation of an IT Project Management Site Template. I thought, hmm, pretty straight forward, but wait, I ran into an issue that I am positive, could have been solved in other ways (List Event Handler)
The requirement was to display an image based on a certain condition, and this condition had to do with lookup of other List Column values.
If you want to display images for a calculated column here are the steps you need to take:
- Modify the FLDTYPES.XML file(or make a copy of it!)
- Search for the field definition "Calculated"
- On the default rendering pattern, paste the following
<Switch>
<Expr>
<GetFileExtension><Column/></GetFileExtension>
</Expr>
<Case Value="giF">
<HTML><![CDATA[<IMG SRC="]]></HTML><Column HTMLEncode="TRUE"/><HTML>"</HTML>
</Case>
<Default>
<Column HTMLEncode="TRUE" AutoHyperLink="TRUE"
AutoNewLine="TRUE"/>
</Default>
</Switch> Create a new Column of type Calculated - put some logic in it like so
=IF(AND(Impact="3",Probability="1"),"/_layouts/images/KPIDefault-1.giF",
IF(AND(Impact="3",Probability="2"),"/_layouts/images/KPIDefault-2.giF",
IF(AND(Impact="3",Probability="3"),"/_layouts/images/KPIDefault-2.giF",
IF(AND(Impact="2",Probability="1"),"/_layouts/images/KPIDefault-1.giF",
IF(AND(Impact="2",Probability="2"),"/_layouts/images/KPIDefault-1.giF",
IF(AND(Impact="2",Probability="3"),"/_layouts/images/KPIDefault-2.giF",
IF(AND(Impact="1",Probability="1"),"/_layouts/images/KPIDefault-0.giF",
IF(AND(Impact="1",Probability="2"),"/_layouts/images/KPIDefault-0.giF",
IF(AND(Impact="1",Probability="3"),"/_layouts/images/KPIDefault-1.giF","other")))))))))
NOTE: The Impact and Probability are columns in the SharePoint List. Based on this logic, I am re-using the images from the KPIs in MOSS and simply pointing to them.
And that's it! You now can output images for your List. Here is how it looks

-