One of my present assignments is to make a custom field type. This field should be showing images in the listview webpart depending on the text value it holds. Now this should be easy to do right? Wrong… for some reason I could not get this to work.
What I want is a completely standard textfield that renders an image for certain texts. There are many blogs describing on how to do this. What I missed though is the fact that you must set <CAMLRendering> to TRUE if you want your HTML to show in the listview webpart.
This is described in MSDN: http://msdn.microsoft.com/en-us/library/aa544201.aspx. They state that:
Optional Boolean. The default is FALSE. Specifies whether the field is rendered on list views using the CAML markup in a RenderPattern element elsewhere within the parent FieldType element. The default FALSE means that the field is rendered on list views by an XSL transform in a fldtypes*.xsl file, which is the standard system for field rendering on list views. (However, this element has no effect on field rendering on Display, New, and Edit forms. A RenderPattern would still be the standard way of rendering the field on a Display form.)
My fieldref_.xml looked like this:
<?xml version="1.0" encoding="utf-8" ?>
<Field Name="FieldTypeClass">Some.Namespace.AndClass, Some.Assembly, Version=188.8.131.52, Culture=neutral, PublicKeyToken=87iu1765432ade40</Field>
<HTML><![CDATA[<img src="/_layouts/IMAGES/myImage.png" />]]></HTML>
<HTML><![CDATA[<img src="/_layouts/IMAGES/OtherImage.png" />]]></HTML>