ustcyier@MOSS

Focus on MOSS2007

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

Calculated Columns - Displaying Images

by oscar 12/1/2007 12:51:00 PM

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:

  1. Modify the FLDTYPES.XML file(or make a copy of it!)
  2. Search for the field definition "Calculated"
  3. 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

      

posted on 2008-12-04 22:15  yier  阅读(309)  评论(2编辑  收藏  举报