Horzontial Edit Feature

Go Search
Home
Tutorials
Features
  

Developing SharePoint > Tutorials > Horzontial Edit Feature
TechNet MOSS 2007 Beta newsgroup the question was asked how to make the Edit form horizontal, the simple answer was using Content Types.  Now a series of Tutorials to achieve just that goal.  Three steps are required
 
1) Create User Control that will override default form.
2) Deploy Content Type.
3) Create custom web part.
 
Hope these tutorials help everyone.
 
 
myHorizEdit.zipmyHorizEdit18 KB

 User Control Template

Before deployment of the Content Type as a SharePoint feature, the user control that will be used needs to be created to override the default ListForm user control template

Before deployment of the Content Type as a SharePoint feature, the user control that will be used needs to be created to override the default ListForm user control template.

To create this new user control use the existing template provided:

 

\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES\DefaultTemplates.ascx

 

To create the initial user control copy the beginning attributes:

 

 

<%@ Control Language="C#" AutoEventWireup="false" %>

<%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>

<%@ Register TagPrefix="wssuc" TagName="ToolBar" src="~/_controltemplates/ToolBar.ascx" %>

<%@ Register TagPrefix="wssuc" TagName="ToolBarButton" src="~/_controltemplates/ToolBarButton.ascx" %>

 

Now search for ListForm, rename the RenderingTemplate the name of the User Control and save as (myHorizEdit.ascx):

 

 

<SharePoint:RenderingTemplate ID="ListForm" runat="server">

<SharePoint:RenderingTemplate ID="myHorizEdit" runat="server">

      <Template>

            <SPAN id='part1'>

                  <SharePoint:InformationBar runat="server"/>

                  <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&nbsp;" runat="server">

                              <Template_RightButtons>

                                    <SharePoint:NextPageButton runat="server"/>

                                    <SharePoint:SaveButton runat="server"/>

                                    <SharePoint:GoBackButton runat="server"/>

                              </Template_RightButtons>

                  </wssuc:ToolBar>

                  <SharePoint:FormToolBar runat="server"/>

                  <TABLE class="ms-formtable" style="margin-top: 8px;" border=0 cellpadding=0 cellspacing=0 width=100% <SharePoint:ListDirection runat="server"/>>

                  <SharePoint:ChangeContentType runat="server"/>

                  <SharePoint:FolderFormFields runat="server"/>

 

                  <SharePoint:ListFieldIterator runat="server"/>

 

                  <SharePoint:ApprovalStatus runat="server"/>

                  <SharePoint:FormComponent TemplateName="AttachmentRows" runat="server"/>

                  </TABLE>

                  <table cellpadding=0 cellspacing=0 width=100%><tr><td class="ms-formline"><IMG SRC="/_layouts/images/blank.gif" width=1 height=1 alt=""></td></tr></table>

                  <TABLE cellpadding=0 cellspacing=0 width=100% style="padding-top: 7px"><tr><td width=100%>

                  <SharePoint:ItemHiddenVersion runat="server"/>

                  <SharePoint:ParentInformationField runat="server"/>

                  <SharePoint:InitContentType runat="server"/>

                  <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&nbsp;" runat="server">

                              <Template_Buttons>

                                    <SharePoint:CreatedModifiedInfo runat="server"/>

                              </Template_Buttons>

                              <Template_RightButtons>

                                    <SharePoint:SaveButton runat="server"/>

                                    <SharePoint:GoBackButton runat="server"/>

                              </Template_RightButtons>

                  </wssuc:ToolBar>

                  </td></tr></TABLE>

            </SPAN>

            <SharePoint:AttachmentUpload runat="server"/>

      </Template>

</SharePoint:RenderingTemplate>

 

You are now ready to deploy Content Type feature using this User Control.

 

 

 Feature Deployment

Instruction on deployment of features in MOSS is covered in the SDK

Instruction on deployment of features in MOSS is covered in the SDK.

To deploy this feature create a directory “myHorizEdit” in the path listed below.

 

\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES

 

Create file feature.xml:

<?xml version="1.0" encoding="utf-8" ?>

<!-- _lcid="1033" _version="12.0.4017" _dal="1" -->

<!-- _LocalBinding -->

<Feature Id="77843BC3-9ED8-438f-84D0-18AE37AB933C"

Title="Horizontal Edit Feature"

Description="Edit form in horizontally"

Version="1.0.0.0"

Scope="Site"

xmlns="http://schemas.microsoft.com/sharepoint/">

<ElementManifests>

     <ElementManifest Location="sColumns.xml" />

     <ElementManifest Location="cType.xml" />

</ElementManifests>

</Feature>

Note: use guidgen tool to create unique Id, and remove the brackets. This will also be used to generate unique ContentType ID & Field ID below:

 

Create file sColumns.xml

 

 

<?xml version="1.0" encoding="utf-8" ?>

<!-- _lcid="1033" _version="12.0.4017" _dal="1" -->

<!-- _LocalBinding -->

<!--

-->

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<Field ID="{CC67C6F3-1519-463c-8EB5-DBB30F73A0EF}"

Name="myCustomText"

SourceID="http://schemas.microsoft.com/sharepoint/v3"

StaticName="myCustomText"

Group="myGroup"

RowOrdinal="0"

Type="Text"

DisplayName="Text Column" />

<Field ID="{E3F01815-7011-4386-AB44-8D100CAAA677}"

Name="myCustomNote"

SourceID="http://schemas.microsoft.com/sharepoint/v3"

StaticName="myCustomNote"

Group="myGroup"

RowOrdinal="0"

Type="Note" NumLines="3"

DisplayName="Text Note" />

<Field ID="{10B2A9AB-2E92-4625-BF72-FF8EB5E44476}"

Name="myCustomDate"

SourceID="http://schemas.microsoft.com/sharepoint/v3"

StaticName="myCustomDate"

Group="myGroup"

RowOrdinal="0"

Type="DateTime" Format="DateOnly"

DisplayName="Date Only" />

</Elements>

The ContentType ID is broken into three section:

ID="0x0102 00 27D3DC756C694e229D3F6275117850E4"

The last part is the generated Guid with only Hex characters. The first part of the Id is the Base content type 0x0102 with is an Calendar (Event) type list.

 

Each content type is delimited by 00.

 

This content type is using the base Events list and adding three additional site columns created to the left. To create other content types change the base content type Id to inherit their fields.

 

Create file cType.xml

 

 

<?xml version="1.0" encoding="utf-8" ?>

<!-- _lcid="1033" _version="12.0.4017" _dal="1" -->

<!-- _LocalBinding -->

<!--

-->

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

<ContentType ID="0x01020027D3DC756C694e229D3F6275117850E4"

Name="myContentType"

Group="myGroup"

     Description="Horizontal Event Edit form."

     Version="0">

<FieldRefs>

<FieldRef ID="{CC67C6F3-1519-463c-8EB5-DBB30F73A0EF}" Name="myCustomText" />

<FieldRef ID="{E3F01815-7011-4386-AB44-8D100CAAA677}" Name="myCustomNote" />

<FieldRef ID="{10B2A9AB-2E92-4625-BF72-FF8EB5E44476}" Name="myCustomDate" />

</FieldRefs>

<XmlDocuments>

<XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">

<FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">

<Display>ListForm</Display>

<Edit>myHorizEdit</Edit>

<New>ListForm</New>

</FormTemplates>

</XmlDocument>

</XmlDocuments>

</ContentType>

</Elements>

The XmlDocument specifies which template to use for either the Display, Edit, or New form.

 

To deploy feature:

stsadm -o installfeature -filename myHorizEdit\feature.xml force

stsadm -o activatefeature -filename myHorizEdit\feature.xml -url http://<site>

 

This will add content type to site, the next step is to create a Calendar List and modify settings to use:

This will now give you the option to add additional Content Types and remove the base Content Type:

 

Please notice after all this work everything is the same, this is because the myHorizEdit.ascx control is a copy of the ListForm, but to verify deployment edit myHorizEdit.ascx and remove: <SharePoint:ListFieldIterator runat="server"/>

 

IISRESET, and notice the edit gives you nothing to edit, will do that next in the custom web part.

 

 

 Custom Web Part

Instruction on deployment of features in MOSS is covered in the SDK

The web part project source is included in the Source Download.

 

This code will need to be added into the Global Assembly Cache, and modify the web.config to include:

<SafeControl Assembly="MULTISY.Public.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b4f611cdf1575c19" Namespace="MULTISY.Public.WebParts" TypeName="*" />

 

 

Changes required in the “myHorizEdit.ascx” file include:

<%@Assembly Name="MULTISY.Public.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b4f611cdf1575c19" %>

<%@Register TagPrefix="MULTISY" Assembly="MULTISY.Public.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b4f611cdf1575c19" namespace="MULTISY.Public.WebParts"%>

 

Where the ListFieldIterator was located add the custom web part:

 

                    

          <MULTISY:mySampleWP

                runat="server"

                ExcludeFields="Attachments;#fRecurrence;#fAllDayEvent;#Description;#WorkspaceLink"

                id="mySampleWP"

                title="myWebPart" />

 

Now the Edit Form will display fields horizontally.

 

It is important to point out that the second row uses Microsoft.SharePoint.WebControls.FormField Class for each cell so the OK button on form will properly update changes to ListItem.

 

ExcludeFields property was added to replicate the same ListFieldIterator property.

 

Enjoy these new capabilities of Microsoft Office SharePoint Server..

 

 
 

 ‭(Hidden)‬ ContentPlaceHolders






























 Team Discussion

There are no items to show in this view of the "Team Discussion" discussion board. To create a new item, click "Add new discussion" below.
 Add new discussion