ドロップダウン リスト ボックスに複数のフィールドを表示する - Greg Collins
in

InfoPath Dev

This Blog

Syndication

Archives

Greg Collins

ドロップダウン リスト ボックスに複数のフィールドを表示する

InfoPath フォームの開発中、ドロップダウン リスト ボックスに複数のフィールドから多くの情報を表示することが必要になる場合があります。これは、手動でビューの .xsl ファイルを変更するだけで簡単に設定できます。このタスクでは、1 つのドロップダウン リスト ボックスに複数のフィールドを表示するための変更を行います。

アプローチ 1
1 つ目の方法は最も簡単です。ビューの .xsl ファイルを手動で変更し、XPath の concat() 関数を使用して、複数のフィールドを結合した値をドロップダウン リスト ボックスに表示します。

たとえば、次のような XSL があるとします。

<option>
    <xsl:attribute name="value">
        <xsl:value-of select="my:EmployeeId"/>
    </xsl:attribute>
    <xsl:if test="$val=my:EmployeeId">
        <xsl:attribute name="selected">selected</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="my:LastName"/>
</option>

これを次のように変更します (変更箇所を赤字で示します)。

<option>
    <xsl:attribute name="value">
        <xsl:value-of select="my:EmployeeId"/>
    </xsl:attribute>
    <xsl:if test="$val=my:EmployeeId">
        <xsl:attribute name="selected">selected</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="concat(my:LastName, ', ', my:FirstName, ' (', my:EmployeeId, ')')"/>
</option>

これらの変更は、デザイン モードでラウンドトリップします。つまり、デザイン モードでフォーム テンプレートを読み込んで変更し、それを保存しても、XSL での変更は失われません。

アプローチ 2
2 つ目は、コード経由でドロップダウン リストを設定する方法です。おそらくこちらの方が信頼性が高くなります。このテクニックは、InfoPath Dev のサンプル フォーム「Fully Editable Drop-Down List Box」で使用されています。コードを使用すると、ドロップダウン リスト ボックスを完全にカスタマイズできます。

©2004 Greg Collins. All rights reserved. Licensed to Autonomy Systems, LLC for display on InfoPathDev.com.

Comments

No Comments

About Kaoru Okumura

Program Manager, Qdabra.com Kaoru worked for ten years at Microsoft as a program manager, and many years at IBM Tokyo Research Lab as an advisory researcher. She led projects on natural language related research and products including Japanese search and proofing tools. Kaoru holds a Master of Science in Mathematics from Kyushu University, and BA from International Christian University. She enjoys performing Butoh dance, and taking photography.
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.