Tuesday, November 22, 2011

SPD to Hide list field in NewForm.aspx

 

Hiding few columns from the default view DataFormWebPart webpart.

 

This article would cover the we can change the new from page of any list. Generally we get to see the new form page with application master page, but here I have changed it to default master page.

Additionally we will also see how to hide even mandatory field. However,  except for the title field SharePoint does not enter any default value.

 

I would suggest to add a new page to the list to show  dataformwebpart and then do changes. I won’t go in detail of how to add pages, rather follow the link below to create/know how to add list page in any list from SPD please refer to the below link.

http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-custom-list-form-HA010119111.aspx

 

The SPD code change would look like below. I am not adding whole of the Placeholdermain content place holder but only the html table where the fields are there.

<table border="0" cellspacing="0" width="100%">

<tr><td colspan="2" style="background-color:olive; font-family:Verdana;font-weight:bold; text-align:center">Test of SPD List Page</td></tr>

<tr><td width="190px" valign="top" class="ms-formlabel">

                <H3 class="ms-standardheader">

                <nobr>Title<span class="ms-formvalidation"> *</span>

                </nobr></H3></td>

<td width="400px" valign="top" class="ms-formbody">

<SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="New" FieldName="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>

<SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="New"/>

</td>

</tr>

<tr><td width="190px" valign="top" class="ms-formlabel">

                <H3 class="ms-standardheader">

                <nobr>Col1</nobr>

                </H3></td>

<td width="400px" valign="top" class="ms-formbody">

<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="_x0043_ol1" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@_x0043_ol1')}"/>

<SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="_x0043_ol1" ControlMode="New"/>

</td></tr>

 

<!--<tr>                <td width="190px" valign="top" class="ms-formlabel">

                <H3 class="ms-standardheader">

                <nobr>Col5 <span class="ms-formvalidation"> *</span></nobr>

                </H3></td>

                <td width="400px" valign="top" class="ms-formbody">

                <SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="New" FieldName="_x0043_ol5" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@_x0043_ol5')}"/>

                <SharePoint:FieldDescription runat="server" id="ff3description{$Pos}" FieldName="_x0043_ol5" ControlMode="New"/>

                </td>

                </tr>-->

               

<tr><td width="190px" valign="top" class="ms-formlabel">

<H3 class="ms-standardheader">

<nobr>Col6</nobr>

</H3>

</td>

<td width="400px" valign="top" class="ms-formbody">

<SharePoint:FormField runat="server" id="ff4{$Pos}" ControlMode="New" FieldName="_x0043_ol6" __designer:bind="{ddwrt:DataBind('i',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@_x0043_ol6')}"/>

<SharePoint:FieldDescription runat="server" id="ff4description{$Pos}" FieldName="_x0043_ol6" ControlMode="New"/>

</td></tr>

<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">

<tr><td colspan="99" class="ms-vb">

<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>

</td></tr></xsl:if>

</table>

 

 

The final output would be something

clip_image002

 

 

Thanks for reading. If you have some other explanation – please post a comment… I’ll be happy to hear.

...HaPpY CoDiNg

Partha (Aurum)

References:

http://office.microsoft.com/en-us/sharepoint-designer-help/CL010082351.aspx?CTT=97

http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-custom-list-form-HA010119111.aspx

 

No comments:

Post a Comment