How to sort the options on a custom dialog popup menu?

New Here ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

I'm developing a custom dialog that will be used to fill out form text fields when inserting stamps.

The code below is in my initialize function:

 

dialog.load({
   "sub1":
   {
      // Note: positive value represents the default item
      "A": -1, 
      "B": -2,
      "C": -3,
      "D": +4, // default item
      "E": -5
   }
});

 

 

The code below is in my  description dictionary, as one of the elements

 

{
   type: "view",
   align_children: "align_left",
   elements:
      [
         {
            type: "cluster",
            name: "Provider",
            elements:
               [
                  {
                     type: "static_text",
                     name: "Select Item",
                     font: "default"
                  },
                  {
                     type: "popup",
                     item_id: "sub1",
                     variable_Name: "sub1",
                     width: 150,
                     height: 20
                  },
               ]
         }
      ]
},

 

 

My question is, how can I prevent acrobat from sorting elements shown in the dropdown menu alphabetically? The way it is, those elements are sorted in alphabetical order but I'd like to have them in the specific order I typed them in the code.

 

obs.: I tried changing the values of the "sub1" dictionary but they don't change the order of the options. The + number does change what is the default option though.

 

i.e. this didn't change the order of the list:

"sub1":
{
   // Note: positive value represents the default item
   "A": -5, 
   "B": -4, 
   "C": -3,
   "D": +2,// default item
   "E": -1
}

 

TOPICS
How to , JavaScript , PDF forms

Views

37

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Aug 02, 2022 Aug 02, 2022

Hi,

For me, you have to push all of them one at a time.

Try that in your script:

	// This dialog box is called when the dialog box is created
	initialize: function (dialog) {
		dialog.load({ "usnm": this.strName });
		dialog.load({ "lsnm": this.strLastName });
		this.loadDefaults(dialog);
	},
	loadDefaults: function (dialog) {
		// Liste des couleurs
		dialog.insertEntryInList({"sub1":{"D": +2}});
		dialog.insertSeparatorEntryInList("sub1");
		dialog.insertEntryInList({"sub1":{"A": -5}});
		dialog.
...

Likes

Translate

Translate
Enthusiast ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

Hi,

For me, you have to push all of them one at a time.

Try that in your script:

	// This dialog box is called when the dialog box is created
	initialize: function (dialog) {
		dialog.load({ "usnm": this.strName });
		dialog.load({ "lsnm": this.strLastName });
		this.loadDefaults(dialog);
	},
	loadDefaults: function (dialog) {
		// Liste des couleurs
		dialog.insertEntryInList({"sub1":{"D": +2}});
		dialog.insertSeparatorEntryInList("sub1");
		dialog.insertEntryInList({"sub1":{"A": -5}});
		dialog.insertEntryInList({"sub1":{"C": -3}});
		dialog.insertEntryInList({"sub1":{"E": -1}});
		dialog.insertEntryInList({"sub1":{"B": -4}});
	},

and you will get:

Capture d’écran 2022-08-02 à 22.13.53.png

@+

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

Thank you, it worked perfectly!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

LATEST

You're welcome, let me know if you need more help for your stamp!

@+

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines