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?

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.

  • 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 Sep 27 '10 at 8:08
  • Please provide a summary for the answer you are linking to. – Nacht Sep 23 '14 at 0:56
  • 1
    The link is broken as of 2017-03-28 – shufler Mar 28 '17 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.

  • 2
    Brilliantly simple and so typical of Msft's leaky programming. – matt May 22 '15 at 2:41
  • 1
    true. thanks for the upvote, really hoping more people use this solution and less people use the others... – Nacht May 22 '15 at 4:09
  • Tremendous - nifty workaround until I can get SP Designer configured – Graham Gold Jul 16 '15 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 Nov 26 '15 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 Jun 26 '17 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). :)

  • 1
    This is very nice and works without you knowing much code - just a teensy bit. – bgmCoder Oct 30 '12 at 15:34
  • Thanks. If anyone needs help with the calculated column formulae, we also have a cheatsheet on our site. – Stu Pegg Oct 30 '12 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 Nov 12 '12 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 Nov 12 '12 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.

  • 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 Sep 24 '10 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy