Expand my Community achievements bar.

Sorting XML data linked to a drop-down list

Avatar

Level 3


I am looking for a javascript code that I can use to sort XML data linked to a drop-down list when the list is accessed by mouse-down. For reasons that I can't get into here, I cannot sort the xml before loading it into the form.

I am using LiveCycle Designer ES 8.2.1

5 Replies

Avatar

Level 10

Hi Dave,

I would to know, how do you set the data items in the dropdownlist?

Is it from a database or is it set manually with JavaScript?

If you set it with JavaScript how do you manage to insert the data items in the dropdownlist?

Avatar

Level 10

Hi,

you can use a XSLT-stylesheet using the <xsl:sort> element to sort your XML data already while it's imported in your form.

LiveCycle Blog: XML-Daten mit XSLT umwandeln//Transform XML Data with XSLT

Avatar

Level 3

I clicked on "List Items" in the Object/Cell tab and made a data connection to an XML file. There are about 600 items in the data source, so I didn't want to type them all in.


Avatar

Level 3

My data is coming from an excel spreadsheet that is updated about once a month. I am creating an XML file from that data and then importing into my pdf. I haven't tried using an XSLT stylesheet to transform it. I'm not familiar with them, so I will have to look into it.

This is the first time that I have pulled in outside data, so I'm trying to learn quickly.

Avatar

Level 10

Hi there,

Good method to sort XML with XSLT!

As I would have suggested you to have a second dropdownlist to be the displayed data view,

If you rather use another method than XSLT, you could try retrieving each data inside the dropdownlist and create an Array out of it.

With the array you can use the method sort(); and once sorted out, you only need to insert them in the displayed dropdownlist data view.

Hope you will manage to make this work!