Edit.aspx 中的 Sharepoint 条件字段 [英] Sharepoint Conditional fields in Edit.aspx

查看:9
本文介绍了Edit.aspx 中的 Sharepoint 条件字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据字段的值在编辑表单中显示某些元数据字段.

I would like to display certain meta data fields in the edit form based on the value of a fields.

示例:用户将文档上传到 Doclib 由那里的经理批准.在项目得到经理批准之前,他们可以更改元数据名称、案例编号、位置.项目获得批准后,我想将名称和案例编号设置为只读.

Example: Users upload a document to the Doclib to be approved by there manager. They are allowed to change the meta data Name,Case No, Location until the item is approved by the manager. Once the item is approved I would like to set Name and Case Number to read only.

满足此要求的最佳方法是什么?

What is the best way to meet this requirement?

如果批准 = 是设置名称和大小写编号 = 只读别的什么都不做.

If approved = yes set Name and Case No = Read only Else do nothing.

我已经尝试了这个方法大约 5 个小时.我相信这可能与 ModerationStatus 不同.可能需要一些特别的东西

I have tried this method for about 5 hours. I believed this may be different for ModerationStatus. Might require something special

print("<xsl:choose>
<xsl:when test="@_ModerationStatus != '0;#approved'">               
<SharePoint:FormField runat="server" id="ff12{$Pos}" ControlMode="Edit" FieldName="Test_x0020_Session" __designer:bind="{ddwrt:DataBind('u',concat('ff12',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Test_x0020_Session')}"/>
<SharePoint:FieldDescription runat="server" id="ff12description{$Pos}" FieldName="Test_x0020_Session" ControlMode="Edit"/>                      
</xsl:when>
<xsl:otherwise>
     <xsl:value-of select="@Test_x0020_Session"></xsl:value-of>
</xsl:otherwise>

");

我可以让它与其他字段一起工作,但不能与 ModerationStatus 一起工作.我也尝试将其更改为 !='0' 和 !='Approved' 和 '0;#Approved'.是不是我做错了什么?

I can get it to work with the other fields but not ModerationStatus. I have also tried changing it to !='0' and !='Approved' and '0;#Approved'. Is there something I am doing wrong?

好像卡在 0;#Approved

Seems like its stuck on 0;#Approved

推荐答案

这可以通过 SharePoint Designer 轻松解决.

This can be easily solved with SharePoint Designer.

  • 您需要为您的列表修改EditForm.aspx
  • 隐藏默认的ListFormWebPart(不要删除它!)
  • 插入自定义编辑项表单(更多详情...)
  • 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...)

自定义表单看起来与默认表单完全相同,但您可以使用 SharePoint Designer 对其进行自定义.下面的代码可用于默认 WSS 问题列表.当Issue Status = Closed时,它会将问题标题显示为只读.

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.

像往常一样,您可能会遇到一些其他问题.我无法在数据视图 Web 部件中获取 @_ModerationStatus 的值.我不知道确切的原因...

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. 在您的文档库中创建一个列
  2. 在工作流 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.

这篇关于Edit.aspx 中的 Sharepoint 条件字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆