Tuesday, June 9, 2009

Custom Calculated List Column













No I'm not talking about creating a regular calculated column here. Recently I was asked whether we can have a custom column in our list which displays a icon image and hyperlinks to a web part page with querystring.
Calculated column seemed to be the best choice. Below are the steps I followed:
  • Create a calculated column in the list.
  • In the formula section add
    ="http://servername/site/doclib/mywebpartpage.aspx?item=/site/doclib/"&[ColumnName]&".docx"

** Url and querystring should be modified according to your needs**

  • Select Single line of text for section "The data type returned from this formula is"
  • Open FldTypes.xml located in \Template\XML\ .
  • Navigate to the node <field name="TypeName">Calculated</field>
  • Navigate to <renderpattern name="DisplayPattern">node
  • Now either add a new case statement or add this code to Default node.Refer to the first image above. Add the html in the default node.
  • Save and Close the file.
  • RESET IIS
  • Refer to the second image above of how the output displays. "View in SharePoint" column has a icon which contains the hyperlink

No comments: