Thursday, March 4, 2010

Custom Field Types in SharePoint

Minimum requriements:

A field type definition. This field type definition is an XML file that contains the information that Windows SharePoint Services needs to correctly render the field, including its column header, on list view pages (such as AllItems.aspx). It is typically also used to render the field on the view list item page (DispForm.aspx) and sometimes it is used to render the field on the New or Edit (list item) pages. It can also declare and define special variable properties of the field type whose values will be set whenever a column is created based on the field type. Most importantly, it contains information about the assembly that includes the compiled field type.

A field class. This is a class whose instances can represent particular fields that are based on your custom field type. This class must inherit from SPField or one of the classes in Windows SharePoint Services that derive from it. The class is compiled into a strong-named assembly and you deploy it to the global assembly cache. In the context of a list view, an SPField object represents a column and its properties, such as whether it can be sorted. In the context of the Display, New, and Edit modes, an SPField object represents a particular field of a list item — a cell in the table that constitutes the list — and the value of that cell in the content database.

A rendering control class. This is a class that can be used, in conjunction with a rendering template (see below), to render your fields in New mode or Edit mode, or, less commonly, in Display mode. This class must inherit from BaseFieldControl or one of the classes in Windows SharePoint Services that derive from it. This class is compiled into the same assembly as the field class.

A rendering template. The rendering template is defined in an .ascx file located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\ControlTemplates.

An editing control for the variable properties of the field type. All field types require a name, a data type, a description, and other common properties; but many field types also have properties that are relevant only to fields of that particular type. These variable properties are set by users in the UI when they create a new column that is based on the field type. Usually, an element in the field type definition (see above) determines how these property setting controls are rendered. But sometimes a special editing control is required. Such a control is defined in an .ascx file that usually has a code-behind file that contains its logic. Creating a special editing control is recommended if you need to perform custom functions, such as complicated computational logic, looking up values from data sources, or custom data validation of the values that a user might choose when configuring a new column.

Source: http://msdn.microsoft.com/en-us/library/ms446361.aspx

No comments:

Post a Comment