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.

2 Answers 2


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.

  • Thanks for your reply. That is exactly what I am doing. The custom field inherits MultiColumn and stores its data like [id];#[value]... Sep 1, 2011 at 8:25
  • What Parent Type are you using in your fldTypes*.XML?
    – Stu Pegg
    Sep 1, 2011 at 19:16
  • I am using MultiColumn as parent type. I considered to try with Lookup as parent type... Sep 2, 2011 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.
    – Stu Pegg
    Sep 2, 2011 at 7:40

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.

  • 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, 2012 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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