Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

3 Answers

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

share|improve this answer
    
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? –  Stuart 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? –  Stuart 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
show 3 more comments

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.

share|improve this answer
add comment

A field type's rendering can be controller by binding it to a BaseFieldControl derived custom control:

http://www.chakkaradeep.com/post/SharePoint-Creating-a-custom-field.aspx

share|improve this answer
1  
I took "in the list" to mean "in the List View". Looks like we've covered both bases between us. :) –  Stuart Pegg Jun 24 '11 at 21:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.