10

how can i force sharepoint2007 (MOSS) to interpret HTML code instead of showing it?

I have a column which calculates a yes or no (depending on other columns) within a HTML (i want to show images too). This column is not interpreted by sharepoint. HTML is shown in the column plain.

What can i do to solve this?

1

5 Answers 5

6

Have a look at the solution described in this post: Using calculated columns to write HTML


original post (links are broken)

elcapitano, my tutorial should work:

http://blog.pathtosharepoint.com/2008/09/01/using-calculated-columns-to-write-html/

A couple notes:

If it doesn't work, feel free to share your HTML string (calculated column output) and I'll take a look.

3
  • after working on the troubleshooting page, it worked! Thanks!!!! Anyway i think i have to develop a system-wide function which allows to display html.
    – Anonymous
    Commented Sep 27, 2010 at 8:08
  • Please provide a summary for the answer you are linking to.
    – Nacht
    Commented Sep 23, 2014 at 0:56
  • 2
    The link is broken as of 2017-03-28
    – shufler
    Commented Mar 28, 2017 at 16:44
14

By far the easiest method to do this is to simply set the "data type returned from this formula" setting on your column to be "Number".

Against all logic, this interprets your formula as HTML. I'm not sure if this works in 2007, but it certainly works in 2010 and 2013. Since there are 10,000 views on this topic and very few up votes, I'm guessing this is a much better answer for the wider community than any of the answers given.

7
  • 2
    Brilliantly simple and so typical of Msft's leaky programming.
    – matt
    Commented May 22, 2015 at 2:41
  • 1
    true. thanks for the upvote, really hoping more people use this solution and less people use the others...
    – Nacht
    Commented May 22, 2015 at 4:09
  • Tremendous - nifty workaround until I can get SP Designer configured Commented Jul 16, 2015 at 19:45
  • 1
    Trying this out with a calculated column that gives an html link, I found that by setting the "data type returned from this formula" to "Date & Time" you can get the result left-aligned instead of right-aligned as well.
    – Lizzan
    Commented Nov 26, 2015 at 9:28
  • 1
    You can't do this anymore in SPO - you can do it on-prem if you have certain extra settings defined. support.microsoft.com/en-us/help/4032106/…
    – bgmCoder
    Commented Jun 26, 2017 at 15:46
3

We've recently released a free HTML Calculated Column; it acts just like a calculated column, but won't escape HTML:

Pentalogic's SharePoint HTML Calculated Column

Disclaimer: I work for Pentalogic; on this project actually. Oh, and I'm afraid you have to sign up for our newsletter, but that isn't a bad trade (in my unbiased opinion). :)

4
  • 1
    This is very nice and works without you knowing much code - just a teensy bit.
    – bgmCoder
    Commented Oct 30, 2012 at 15:34
  • Thanks. If anyone needs help with the calculated column formulae, we also have a cheatsheet on our site.
    – Stu Pegg
    Commented Oct 30, 2012 at 18:12
  • Nice work @StuartPegg , it does the work perfectly. First I tried the JavaScript-way, it's only 2 lines with jQuery after all. But the asynchronous loading and ExpGroupRenderData (and ExpGrou...) didn't want to play along.
    – eirikb
    Commented Nov 12, 2012 at 10:02
  • @eirikb: Yeh, the 2010 list view AJAX is a mess. It gets worse when you add paging and/or web part auto-updating. Thankfully HTMLCC didn't need these fixes, although Highlighter did. :/
    – Stu Pegg
    Commented Nov 12, 2012 at 10:34
2

If you are bound to using a ListView Webpart (OOTB web part), then you can use Christophe's Text2HTML script. Elaborating on James's answer, you can also look at Marc Anderson's DVWPCalcHTMLColumn XSLT to do the heavy lifting.

1

If you are developing a DataViewWebPart, you can force sharepoint to render the HTML as opposed to displaying the raw text by using disable-output-escaping set to yes.

1
  • Thanks for your idea. If it is possible, i want to solve this without coding. I tried the tutorial at blog.pathtosharepoint.com/2008/09/01/… by inserting Javascript, but it wont work.
    – Anonymous
    Commented Sep 24, 2010 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.