alphabetize drop down list

A

abc

i'm connect to access db...

user is allowed to create new "unit" and clicks refresh to populate
into dropdown list.. is there a way to alphabetize this drop down list
once it re-populates with the "new unit"?
 
S

Scott Roberts [MSFT]

Unfortunately, there is no way to sort the list using the InfoPath Designer. However, you can extract the form files and edit the XSL to make this happen. You can add xsl:sort to do sorting. However, you will need to add the xd:preserve attribute to your template so that you will be able to open your Form Template in the Designer without losting your changes. Here is an example of template that has the xd:preserve attribute (from the InfoPath SDK):

<xsl:template match="my:field1" mode="xd:preserve">
<div>
The value of field1 is <xsl:value-of select="."/>
</div>
</xsl:template>

You would then place all the XSL for the list inside of this template and add the xsl:sort statement in the xsl:for-each for the list. The xsl:for-each would look something like this:

<xsl:for-each select="my:group1/my:group2">
<xsl:sort select="my:field2" order="ascending"/>
<option>
<xsl:attribute name="value">
<xsl:value-of select="my:field2"/>
</xsl:attribute>
<xsl:if test="$val=my:field2">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="my:field2"/>
</option>
</xsl:for-each>

I hope this helps.

- Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top