Help us understand the problem. What is going on with this article?

【SharePoint 2013】カスタムフォームで文字列の状態で項目の表示・非表示を切り替える

More than 1 year has passed since last update.

SharePoint Designer 2013 でリストのカスタムフォームを作成した際に、
ある列の状態によって項目の表示/非表示を制御したいという要望は多いと思います。

文字列を XPath で比較する際のサンプルです。[承認状況(ApprovalStatus)]列の文字列を比較し、それぞれ [一次承認]、[二次承認]、[承認済] の時に表示する項目を切り替えます。

前方一致、部分一致、完全一致のサンプルを書きました。

<xsl:choose>
  <xsl:when test="starts-with(@ApprovalStatus, '一次承認')"><!-- 前方一致 -->
    <tr>
      <td width="190px" valign="top" class="ms-formlabel">
        <H3 class="ms-standardheader">
          <nobr>一次承認</nobr>
        </H3>
      </td>
      <td width="400px" valign="top" class="ms-formbody">
        <SharePoint:FormField runat="server" id="ff16{$Pos}" ControlMode="Edit" FieldName="PrimaryApproved" __designer:bind="{ddwrt:DataBind('u',concat('ff16',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@PrimaryApproved')}" />
        <SharePoint:FieldDescription runat="server" id="ff16description{$Pos}" FieldName="PrimaryApproved" ControlMode="Edit" />
      </td>
    </tr>
  </xsl:when>
  <xsl:when test="contains(@ApprovalStatus, '二次承認')"><!-- 部分一致 -->
    <tr>
      <td width="190px" valign="top" class="ms-formlabel">
        <H3 class="ms-standardheader">
          <nobr>二次承認</nobr>
        </H3>
      </td>
      <td width="400px" valign="top" class="ms-formbody">
        <SharePoint:FormField runat="server" id="ff17{$Pos}" ControlMode="Edit" FieldName="SecondaryApproved" __designer:bind="{ddwrt:DataBind('u',concat('ff17',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@SecondaryApproved')}" />
        <SharePoint:FieldDescription runat="server" id="ff17description{$Pos}" FieldName="SecondaryApproved" ControlMode="Edit" />
      </td>
    </tr>
  </xsl:when>
  <xsl:when test="@ApprovalStatus = '承認済'"><!-- 完全一致 -->
    <tr>
      <td width="190px" valign="top" class="ms-formlabel">
        <H3 class="ms-standardheader">
          <nobr>承認日</nobr>
        </H3>
      </td>
      <td width="400px" valign="top" class="ms-formbody">
        <xsl:value-of select="ddwrt:FormatDateTime(string(@ApprovalDate), 1041, 'yyyy/MM/dd (ddd) HH:mm')" />
      </td>
    </tr>
  </xsl:when>
</xsl:choose>

参考サイト

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした