SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to implement a custom field type where sorting and grouping in list view webparts will work correctly?

I have a scenario with a cross-site collection lookup field we implemented and neither sorting or grouping in the XSLT list view webpart works as expected.

share|improve this question

I believe sorting and grouping are based on the actual stored data. If you've got a Custom Field Type doing such things I imagine you're not storing data in a manner SharePoint would recognise (and hence will also run into similar issues with the obstinate DataSheet view).

If you're overriding SPFieldLookup, I'd recommend trying to emulate the Lookup field storage format. Since SharePoint doesn't actually check the ID's the field contains (at least not on render), you may fool it into thinking it's dealing with normal Lookup data.

share|improve this answer
Thanks for your reply. That is exactly what I am doing. The custom field inherits MultiColumn and stores its data like [id];#[value]... – Bernd Rickenberg Sep 1 '11 at 8:25
What Parent Type are you using in your fldTypes*.XML? – Stuart Pegg Sep 1 '11 at 19:16
I am using MultiColumn as parent type. I considered to try with Lookup as parent type... – Bernd Rickenberg Sep 2 '11 at 7:28
It would probably be a good idea to try it; it's more likely SharePoint will handle it as if it was a lookup. Additionally, inheriting from SPFieldLookup (for your base class) and SPFieldLookupValue (for your Value class) will allow you to imitate a lookup's behaviour more closely. – Stuart Pegg Sep 2 '11 at 7:40
up vote 1 down vote accepted

The solution we ended up with is as follows:

  • The field inherits from SPFieldText
  • The xml definition has Text as parent type
  • Storage format [id]#;[value]
  • In the field controls Value property we return a SPFieldLookupValue
  • XSL template to display [value] only

Returning the SPFieldLookupValue did the trick. Simply changing the storage format and/or parent types did no help. The only drawback with this solution is that the filter choices (when filtering a list) display as [id]#;[value] instead of the [value] only.

share|improve this answer
It looks like the filtering render is determined by SchemaFieldInfo.ComputeFieldValueType(). This method selects an SPFieldRenderWorker() to render the field. Unfortunately there doesn't appear to be a way to override it... – Alex Angas Jun 13 '12 at 3:21

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.