Hello,
ever tried to use custom field properties in rendering field content on a list view in sharepoint 2010? doesn't work..
so you google it (naturally) -
you hear about a magic way to deliver - CAMLRendering=TRUE, but hey - that doesn't work !!!
you go to msdn and find out that PropertySchema and RenderPattern are obsolete, but what is the way to do it in 2010, no one tells..
after a day of searching and wondering, i want to share my findings with you.
first of all, i still don't have a clue about how it suppose to be done in SharePoint 2010, but here's a working solution that will get you through meanwhile:
1. fldtypes_MyField.xml:
leave it as it was (or should be) for Moss 2007 - with rendering pattern and property schema, etc..
important: add the following properties AllowBaseTypeRendering & CAMLRendering !
for example:
<FieldTypes>
<FieldType>
<Field Name="TypeName">MyField</Field>
<Field Name="ParentType">Text</Field>
<Field Name="TypeDisplayName">TypeDisplayName;</Field>
<Field Name="TypeShortDescription">TypeDisplayName;</Field>
<Field Name="UserCreatable">TRUE</Field>
<Field Name="Sortable">TRUE</Field>
<Field Name="Filterable">TRUE</Field>
<Field Name="FieldTypeClass">MyField, MyField, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...</Field>
<Field Name="FieldEditorUserControl">/_controltemplates/MyFieldFieldEditor.ascx</Field>
<Field Name="AllowBaseTypeRendering">TRUE</Field>
<Field Name="CAMLRendering">TRUE</Field>
<PropertySchema>
<Fields>
<Field Hidden="TRUE" Name="MyCustomProperty" DisplayName="MyCustomProperty" Type="Text">
</Field>
</Fields>
<Fields></Fields>
</PropertySchema>
<RenderPattern Name="HeaderPattern">
<HTML>
<![CDATA[
<script type="text/javascript" language="javascript" src="/_layouts/MyFieldHelper.js"></script>
]]>
</HTML>
<!-- copy the rest of the header pattern of base field -->
</RenderPattern>
<FieldType>
<Field Name="TypeName">MyField</Field>
<Field Name="ParentType">Text</Field>
<Field Name="TypeDisplayName">TypeDisplayName;</Field>
<Field Name="TypeShortDescription">TypeDisplayName;</Field>
<Field Name="UserCreatable">TRUE</Field>
<Field Name="Sortable">TRUE</Field>
<Field Name="Filterable">TRUE</Field>
<Field Name="FieldTypeClass">MyField, MyField, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...</Field>
<Field Name="FieldEditorUserControl">/_controltemplates/MyFieldFieldEditor.ascx</Field>
<Field Name="AllowBaseTypeRendering">TRUE</Field>
<Field Name="CAMLRendering">TRUE</Field>
<PropertySchema>
<Fields>
<Field Hidden="TRUE" Name="MyCustomProperty" DisplayName="MyCustomProperty" Type="Text">
</Field>
</Fields>
<Fields></Fields>
</PropertySchema>
<RenderPattern Name="HeaderPattern">
<HTML>
<![CDATA[
<script type="text/javascript" language="javascript" src="/_layouts/MyFieldHelper.js"></script>
]]>
</HTML>
<!-- copy the rest of the header pattern of base field -->
</RenderPattern>
<RenderPattern Name="DisplayPattern">
<Switch>
<Expr>
<Property Select="MyCustomProperty" HTMLEncode="TRUE"/>
</Expr>
<Case Value="">
<Column HTMLEncode="TRUE"/>
</Case>
<Default>
<Property Select="MyCustomProperty" HTMLEncode="TRUE"/>
<!-- call js function inside HTML element, like in Moss -->
</Default>
</Switch>
</RenderPattern>
</FieldType>
</FieldTypes>
<Switch>
<Expr>
<Property Select="MyCustomProperty" HTMLEncode="TRUE"/>
</Expr>
<Case Value="">
<Column HTMLEncode="TRUE"/>
</Case>
<Default>
<Property Select="MyCustomProperty" HTMLEncode="TRUE"/>
<!-- call js function inside HTML element, like in Moss -->
</Default>
</Switch>
</RenderPattern>
</FieldType>
</FieldTypes>
2. fldtypes_MyField.xsl:
this one is new for SharePoint 2010, and it goes to Templates\Layouts\Xsl
in order to your js calls will be evaluated properly, you need these templates:
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema"
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
version="1.0"
exclude-result-prefixes="xsl msxsl ddwrt"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:SharePoint="Microsoft.SharePoint.WebControls"
xmlns:ddwrt2="urn:frontpage:internal">
xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
version="1.0"
exclude-result-prefixes="xsl msxsl ddwrt"
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:asp="http://schemas.microsoft.com/ASPNET/20"
xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:SharePoint="Microsoft.SharePoint.WebControls"
xmlns:ddwrt2="urn:frontpage:internal">
<xsl:template match="FieldRef[@FieldType='MyField']" mode="header">
<th class="ms-vh2" nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)">
<script language="Javascript" type="text/javascript" src="/_layouts/MyFieldHelper.js" />
<xsl:call-template name="dvt_headerfield">
<xsl:with-param name="fieldname">
<xsl:value-of select="@Name" />
</xsl:with-param>
<xsl:with-param name="fieldtitle">
<xsl:value-of select="@DisplayName" />
</xsl:with-param>
<xsl:with-param name="displayname">
<xsl:value-of select="@DisplayName" />
</xsl:with-param>
<xsl:with-param name="fieldtype">
<xsl:value-of select="@FieldType" />
</xsl:with-param>
</xsl:call-template>
</th>
</xsl:template>
<th class="ms-vh2" nowrap="nowrap" scope="col" onmouseover="OnChildColumn(this)">
<script language="Javascript" type="text/javascript" src="/_layouts/MyFieldHelper.js" />
<xsl:call-template name="dvt_headerfield">
<xsl:with-param name="fieldname">
<xsl:value-of select="@Name" />
</xsl:with-param>
<xsl:with-param name="fieldtitle">
<xsl:value-of select="@DisplayName" />
</xsl:with-param>
<xsl:with-param name="displayname">
<xsl:value-of select="@DisplayName" />
</xsl:with-param>
<xsl:with-param name="fieldtype">
<xsl:value-of select="@FieldType" />
</xsl:with-param>
</xsl:call-template>
</th>
</xsl:template>
<xsl:template match="FieldRef[@FieldType='MyField']" mode="body">
<xsl:param name="thisNode" select="." />
<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" />
</xsl:template>
</xsl:stylesheet>
<xsl:param name="thisNode" select="." />
<xsl:value-of select="$thisNode/@*[name()=current()/@Name]" disable-output-escaping="yes" />
</xsl:template>
</xsl:stylesheet>
all other stuff - MyField, MyFieldEditor, Field Rendering Control, custom property storage work around all remains the same.
?
?happy coding,
?Genady
Loading...
Add your comment
Comments are not meant for support. If you experiencing an issue, please open a support request.
Reply to: from
Development
Riyan Arshad | January 28, 2025
As a skilled SharePoint developer, I have spent years customizing forms and workflows. My goal is to speed up business processes and improve user experiences. The ability to customize SharePoint to fit individual organizational demands has always been a challenging and rewarding endeavor.
Today, I'll discuss how to create custom SharePoint...
Development
Vladi Gubler | March 27, 2025
The best way to show off your product is of course letting your potential customers try it out. In our case, Ultimate Forms is a Microsoft SharePoint application, so it needs SharePoint to run.
Of course, potential customers can easily install it and we even provide an installation wizard that will completely automate and streamline the...
Development
Will Cooper | May 15, 2025
Dynamic Forms are an essential part of SharePoint solutions. Dynamic Forms change in appearance and functionality according to rules defined in the form. It does so in real time as the user fills out the form. This is the opposite of out-of-the-box static SharePoint forms which don't change in appearance or functionality.
Learning how to how to...