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
Flexible Forms
Convenient responsive forms, featuring tabs, permissions, dynamic rules, repeating sections, electronic signatures and input validation
Intuitive Automation
Replace complex workflows with simple, but versatile actions to create and update data inside SharePoint and in a variety of integrated applications
Clear Reporting
Present data as actionable insights with detailed shareable reports, dashboards, calendars and charts
100’s of Templates
Build and replicate business solutions with ease, selecting from our vast free library and creating your own custom templates
Dive deeper
Watch a short introductory video showcasing the different unique capabilities of UltimateForms.