300 likes | 366 Views
Minneapolis Office Developer Interest Group (MODIG). Neil Iversen Inetium. March 25, 2008 Custom Column Development. http://justaddcode.com/. The Plan. Introduction You are here Feature Presentation Custom Columns Next Topic Selection Random Stuff. User Group Goals.
E N D
Minneapolis Office Developer Interest Group (MODIG) Neil Iversen Inetium March 25, 2008 Custom Column Development http://justaddcode.com/
The Plan • Introduction You are here • Feature Presentation • Custom Columns • Next Topic Selection • Random Stuff
User Group Goals • Provide a community for SharePoint Developers • Share development knowledge • Exchange tips/tricks/other/free pizza • Know that SPSimpleFormattingEncodedResourceExpressionBuilder is the longest Object Model Class Name
User Group Format • Presentations • 1-2 per meeting • Hopefully Demo Heavy (Slides are for MBAs) • Highlights of Nifty Things • See next slide • QA/Discussion/Random Things
Call for Cool Stuff • Created something cool? • Send Screenshots or Videos • We’ll try to feature some items here
Sharepointmn.com/modig/ • Our current home • Meeting information • Usually has the right time • Previous presentations • Running on SharePoint • As required by SharePoint User Group Law
Upcoming • Next Meeting • April 17 (5:30pm) • Topic: TBD – Hopefully later today • MNSPUG • April 9 (9:00am – Noon) • Topic : TBD (sharepointmn.com)
Custom Fields – A Code Heavy Approach • Custom Column Intro • Basic Column Development • Deploying Columns • Developing Fancier Columns • Questions
Custom Fields/Columns/Types • No Matter What you Call It • They’re fun! • Create for Special Purposes • Complex Data • Increased Validation • Prettier UI
Custom Fields/Columns/Types • Derived From SPField • SPFieldText • SPFieldNumber • SPFieldMultiChoice • … • UI Derived From BaseControlTemplate • XML Defined • 12\TEMPLATE\XML • Core Fields are in FLDTYPES.XML
Custom Fields Schema <?xml version="1.0" encoding="utf-8" ?> <FieldTypes> <FieldType> <Field Name="TypeName">Data Field - Just Add Code</Field> <Field Name="ParentType">MultiChoice</Field> <Field Name="TypeDisplayName">Data Field - Just Add Code</Field> <Field Name="TypeShortDescription">A Practical Custom Field</Field> <Field Name="FieldTypeClass">MODIG0803.Fields.DataField, MODIG0803.Fields, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c0d2e6ac5478941</Field> <Field Name="UserCreatable">TRUE</Field> </FieldType> </FieldTypes>
Deploying A Field • DLLs • Installed into the GAC • FLDTYPE • 12\TEMPLATE\XML\ • iisreset • Cross Fingers • It never hurts
Advanced Custom Fields Schema <?xml version="1.0" encoding="utf-8" ?> <FieldTypes> <FieldType> <Field Name="TypeName">Data Field - Just Add Code</Field> <Field Name="ParentType">MultiChoice</Field> <Field Name="TypeDisplayName">Data Field - Just Add Code</Field> <Field Name="TypeShortDescription">A Practical Custom Field</Field> <Field Name="FieldTypeClass">MODIG0803.Fields.DataField, MODIG0803.Fields, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c0d2e6ac5478941</Field> <Field Name="UserCreatable">TRUE</Field> <PropertySchema> <Fields> <Field Name="Another Field" DisplayName="Another Field I can See" ShowInNewForm="TRUE" ShowInEditForm="TRUE" Type=“Number" Hidden="FALSE"> </Field> </Fields> </PropertySchema> </FieldType> </FieldTypes>
Advanced Custom Fields Schema <?xml version="1.0" encoding="utf-8" ?> <FieldTypes> <FieldType> <Field Name="TypeName">Data Field - Just Add Code</Field> <Field Name="ParentType">MultiChoice</Field> <Field Name="TypeDisplayName">Data Field - Just Add Code</Field> <Field Name="TypeShortDescription">A Practical Custom Field</Field> <Field Name="FieldTypeClass">MODIG0803.Fields.DataField, MODIG0803.Fields, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c0d2e6ac5478941</Field> <Field Name="UserCreatable">TRUE</Field> <RenderPattern Name="DisplayPattern"> <HTML><![CDATA[Help, I'm <b>]]></HTML> <Column HTMLEncode="TRUE" /> <HTML><![CDATA[</b>Surrounded!]]></HTML> </RenderPattern> </FieldType> </FieldTypes>
Render Patterns • HeaderPattern – Column Title • DisplayPattern – List Item View • EditPattern – Edit Form View • NewPattern – New Form View • PreviewDisplayPattern • PreviewEditPattern • PreviewNewPattern
Control State Sequence • Field Is Loaded • GetFieldValue - Restored from ‘Serialized’ state • Field Rendering Control is Loaded • .Value is SET • Control Mode Property • Tied to action against ListItem • SPControlMode • Display, Edit, New, Invalid • Value is retrived via GET • GetValidatedString
Custom Validation – Server Side • Override GetValidatedString(Object value) • Final Call in Field Setting Lifecycle • Called during most Save’s • Ex: SPListItem.Properties[“MyValue”] • Not Always Called • Web Services • RPC • DataSheets • Proper Validation Error: SPFieldValidationException • Can be used to ‘set’ the final value
Field Validation – UI Side • Override Validate() • Set the IsValid property • ErrorMessage to the text of the Error • SDK Example: if (Field.Required && (Value == null || Value.ToString().Length == 0)) { this.ErrorMessage= Field.Title + " must have a value." IsValid= false; return; }
Adding Useful Features • CONTROLTEMPLATES • ASCX File for a Field • Data Access Code Behind • Pull in and validate data against external Systems • Expand UI Functionality • AJAX.NET • Silverlight(http://www.ssblueprints.net/sharepoint/)
Summary • Fields are Fun • Difficult Learning Curve • State Management is Key • Validation is Two Fold • Field Level Validation • UI Level Validation • Neither always run • EventReciever for True Validation
Next Meeting Planning • Possible Topics • PowerShell and SharePoint for Developers • Using the MS AJAX Framework in SharePoint • Managing Context in SharePoint • Introduction to Workflow • Silverlight 2 and SharePoint • …
Random Stuff Neil Iversen Inetium http://justaddcode.com Feedback Forms/Giveaway Mingle, Eat, Feedback See you next time!