When creating a custom field in SharePoint 2010, what method do I need to override to control what is rendered for the custom field type in the list where it is used?
I tried overriding GetFieldValue
to no effect.
When creating a custom field in SharePoint 2010, what method do I need to override to control what is rendered for the custom field type in the list where it is used?
I tried overriding GetFieldValue
to no effect.
@Marek is right in his assertion that you should use XSLT. However, in 2010 (only) there are functions you can override to alter a field's output:
Each of these accepts an Object value
input, which is either the raw data directly from the list, or the output from the <RenderPattern Name="DisplayPattern">
in the fldTypes...xml (if you're using <Field Name="CAMLRendering">TRUE</Field>
).
The output from whichever of these functions is used is then pushed through the XSLT (if you've provided any) and rendered.
I haven't seen any examples of this method being used in the wild, however (we don't use it due to 2007 incompatibility) so I'd advise caution.
BaseFieldControl
overrides get hit - but these methods jsut don't get called.
SPMultiLineText
- I'm trying to make a Markdown column :) I've got it rendering properly in item Display forms via a custom rendering control which calls GetFieldValueAsHTML
but not in the list.
SharePoint 2010 renders fields on a list view is with XSLT style sheets, so there is no method to override. If you want a your own way of rendering on list views, you need to create a custom XSLT style sheet named fldtypes_*.xsl
and deployed it to (14 hive)\TEMPLATE\LAYOUTS\XSL
.
A field type's rendering can be controller by binding it to a BaseFieldControl derived custom control:
https://www.chakkaradeep.com/2008/12/15/sharepoint-creating-a-custom-field/