I want to create a custom field type in a SharePoint 2010 development project (which I want to publish as as “walkthrough” on this blog )
Therefore I need to inspect the source XML data that is used for XSLT rendering on a lists view page, e.g. “AllItems.aspx”
This is the result:
You see here for each field (column): The source XML and the items field value behind the XML data.
For the demo above I created a new custom list. It has some fields:
- Title : Single line of text
- Choice Field : Choice field with 3 choice values
- Date Field : Date only field
- Lookup Field: Lookup field to the “Start Time” field of the standard Team Site “Calendar” list. (Additional field in view: “End Time”)
- People Picker Field: People or Group field with “People only”.
I added a single item.
That’s the set.
For the lookup field you get this result XML data:
<FieldRef Name="Lookup_x0020_Field" Type="Lookup" FieldType="Lookup" Encoded="TRUE" DisplayName="Lookup Field" ID="da1fb516-3300-47e9-8734-33db5479876e" />
For the “Title” field you get this result XML data:
<FieldRef Name="LinkTitle" ListItemMenu="TRUE" Type="Computed" FieldType="Computed" DisplayName="Title" ID="82642ec8-ef9b-478f-acf9-31f7d45fbc31" ClassInfo="Menu" ListItemMenuAllowed="Required" LinkToItemAllowed="Prohibited" />Test Text
(This field is “Computed”. In the view you do not see the “Title” field itself. You see a “computed” field named “LinkTitle” instead.)
If I want to develop a custom field type I need to create a XSL transformation for the field data. Therefore I need to refer to the source XML data. But at development time I do not know the exact structure and content of the XML data. So I modified a file in the SharePoint hive….
NEVER do the following in a productive SharePoint 2010 farm!
1. Look for the file “C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTSXSLfldtypes.xsl”
2. Open it.
3. Look for this line:
<xsl:template name="PrintField" ddwrt:dvt_mode="body" ddwrt:ghost="always">
4. Before this line insert this XSLT code:
5. Then you have to modify the node starting with “<xsl:template name="PrintField" ddwrt:dvt_mode="body" ddwrt:ghost="always">”. Insert the highlighted line of the snipped below:
6. Restart the IIS.
7. Reload the list view. – Now you’ll see the fields source XML data.