3

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.

  • I have the same problem but using sharepoint services 3.0 who can help me, I need run querys in custum fields when the list view or load. I dont know how run a custom handler for list event. tks. JosePa. – user6035 Dec 15 '11 at 18:02
4

@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.

  • Unless I've missed something, these aren't actually called when rendering to a regular list view. – Rawling Aug 16 '12 at 7:38
  • @Rawling: I'm guessing you're using 2007, or possibly a 2007 site migrated to 2010? – Stu Pegg Aug 16 '12 at 7:40
  • Nope, 2010 here. I don't -think- I've missed anything in my implementation - my constructors and BaseFieldControl overrides get hit - but these methods jsut don't get called. – Rawling Aug 16 '12 at 7:49
  • Could be to do with your field type. Which SPField derivative are you inheriting from? – Stu Pegg Aug 16 '12 at 8:42
  • I'm inheriting 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. – Rawling Aug 16 '12 at 8:44
2

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.

1

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/

  • 1
    I took "in the list" to mean "in the List View". Looks like we've covered both bases between us. :) – Stu Pegg Jun 24 '11 at 21:53
  • This link is dead. Editing answer to provide new link. – Nullldata Jul 26 '18 at 7:35

Your Answer

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