Minneapolis Office Developer Interest Group (MODIG) March 25, 2008 Custom Column Development Neil Iversen Inetium
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)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 Data Field - Just Add Code MultiChoice Data Field - Just Add Code A Practical Custom Field MODIG0803.Fields.DataField, MODIG0803.Fields, Version= , Culture=neutral, PublicKeyToken=1c0d2e6ac TRUE
Deploying A Field DLLs Installed into the GAC FLDTYPE 12\TEMPLATE\XML\ iisreset Cross Fingers It never hurts
Demo – Our First Field
Advanced Custom Fields Schema Data Field - Just Add Code MultiChoice Data Field - Just Add Code A Practical Custom Field MODIG0803.Fields.DataField, MODIG0803.Fields, Version= , Culture=neutral, PublicKeyToken=1c0d2e6ac TRUE <Field Name="Another Field" DisplayName="Another Field I can See" ShowInNewForm="TRUE" ShowInEditForm="TRUE" Type=“Number" Hidden="FALSE">
Demo – More Advanced Schema
Advanced Custom Fields Schema Data Field - Just Add Code MultiChoice Data Field - Just Add Code A Practical Custom Field MODIG0803.Fields.DataField, MODIG0803.Fields, Version= , Culture=neutral, PublicKeyToken=1c0d2e6ac TRUE ]]> Surrounded!]]>
Render Patterns HeaderPattern – Column Title DisplayPattern – List Item View EditPattern – Edit Form View NewPattern – New Form View PreviewDisplayPattern PreviewEditPattern PreviewNewPattern
Demo – More Advanced Schema
Control StateSequence 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
DEMO – What does that Look Like?
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
DEMO – Odd Validation
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; }
DEMO – Odd Validation
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 (
DEMO - Lets get (or fake) some Data!
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
Questions?
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 Feedback Forms/Giveaway Mingle, Eat, Feedback See you next time!