Sharepoint Conditional fields in Edit.aspx

匆匆过客 提交于 2019-12-03 21:32:30

This can be easily solved with SharePoint Designer.

  • You will need to modify EditForm.aspx for your list
  • Hide the default ListFormWebPart (Do not delete it!)
  • Insert custom edit item form (more details...)

Custom form will look exactly the same as the default one, but you will be able to customize it with SharePoint Designer. The code below can be used for default WSS Issues list. It will show Issue title as read-only when Issue Status = Closed.

<xsl:choose>
    <xsl:when test="@Status != 'Closed'">
        <SharePoint:FormField runat="server" id="ff1{$Pos}" ControlMode="Edit" FieldName="Title" __designer:bind="{ddwrt:DataBind('u',concat('ff1',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>
        <SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Title" ControlMode="Edit"/>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="@Title"></xsl:value-of>
    </xsl:otherwise>
</xsl:choose>

You can apply the same logic for your custom lists or/and requirements.

As usual, you might run to some additional problems. I was not able to get the value of @_ModerationStatus in Data View Web Part. I do not know the exact reason...

Here is a simple workaround:

  1. Create a Column in your Document Library
  2. Create a new in workflow SharePoint Designer.

It should fire when item is changed and copy the value of approval status to newly created column.

You can use the custom column for conditional formatting.

Follow Toni's comments but for your _ModerationStatus field use following XSLT function:

<xsl:when test="not(starts-with(@_ModerationStatus,'0'))">
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!