HTML Calculated Column – Updated script v2.1

I have updated the TextToHTML script to add support for preview panes. You can get the new version (v 2.1) on the download page.

SharePoint uses a function called “showpreview1″ to render preview panes. My script appends the “text to HTML” transformation to this default function.

Note that since version 2.0, you don’t need DIV tags anymore in your HTML formulas. The script will identify any HTML string, with upper case tags (DIV, SPAN, IMG, A, etc.) or lower case (div, span, img, a, etc.). For this, the script relies on regular expressions, like this one used for list views:
RegExp("^\\s*<([a-zA-Z]*)(.|\\s)*/\\1?>\\s*$")

If you haven’t heard about the HTML Calculated Column yet, check out these links:
- the method, explained (includes version 1.0 of the script)
- an example: apply color coding to lists
- a formula generator for color coding
- a troubleshooting page

…Or read the whole series (~30 posts).

About these ads
  1. This rocks. Thanks so much for putting it together. And it’s so easy to use! I wanted friendly links to show and got exactly what I needed :)

    • neil
    • July 22nd, 2009

    does any of this color-coding work in datasheet view?

    • unfortunately no. The datasheet view is not html, it is an ActiveX (IE specific) control.

    • Nancy
    • July 24th, 2009

    If I right-click on my list view in SPD and convert ot XSLT data view, I want those html columns to render just as they do in the regular list view.

    You’re saying that there is no way for html columns to properly render in a data view?

    • Nancy, my reply was for the datasheet view – an Excel-like view based on ActiveX controls.
      What you’re creating with SPD are Data View Web Parts, which render regular html.

    • Nancy
    • July 24th, 2009

    What I was trying ot say was-

    I use your formula to successfully render html in calculated columns in regular list views.

    In SPD, if I want to convert the list view to XSLT data view, I lose the HTML formatting.

    Are there changes to your script that will enable the HTML? Or some other way to get it back?

  2. Hi Christophe. I love the script, I have used it so much that I would like to add it to my master page. I did this, and it worked everywhere except for the EditForm page of an list. When opening the EditForm.aspx page with this script in the master page, the page never loads and the browser becomes unresponsive. This is the case even if it is a list without a calculated html column. I tried it from 2 different machines, one with IE8 and one with IE 7. I also tried removing it from the master page and just adding it in a content query web part on the edit form, which I do not recommend because you cannot even open the page in edit mode after that.

    Any ideas on what the problem might be or what I can troubleshoot.

    • I should clarify, since I made a typo. When I add it the script to the master page, all of the editform.aspx pages lock on loading, even if there is not a calculated column. So it seems like maybe there is some kind of conflict here.

  3. Christophe, I clicked on your link above for the latest script, bu the link sends me to:

    http://www.pathtosharepoint.com/Downloads/Forms/AllItems.aspx

    and it just hangs there. is the script anywhere else so that I can download it and use it? Thanks!

    • Maybe there was a temporary problem with the site… I just checked and it is working fine now.

    • John
    • January 24th, 2013

    Hi Christophe,

    I’m trying to use this on my task list in Foundation 2010. I’m using the latest version. But when I group items, any item that is rendered last shows only the text. I’ve done some investigation, and it seems that the textToHtml function isn’t being called for that item. Any ideas what may be causing that?

    Thanks in advance…

    John

    • John, for SP 2010 see more recent articles (for example those published in 2010, or more recently in the past few months).

  1. July 9th, 2009
  2. July 22nd, 2009

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 262 other followers

%d bloggers like this: