Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Sort items inside a listbox

Community Expert ,
Nov 14, 2019 Nov 14, 2019

I have some listboxes whose items are filled in by a script and/or via a CSV.


1. I would like items containing "T*T" to appear at the top of the list, sorted alphabetically. (As this word is censored by the forum I wrote it "T * T", you can see it on the screenshot)
2. I would like items containing "ADE" (and not containing "T*T") to appear next, sorted alphabetically.
3. And I would like all the other items to appear after, sorted alphabetically.

 

See screenshot: white list is the current, yellow list is what I want.

Is it possible?

 

Capture_019.png


Acrobate du PDF, InDesigner et Photoshopographe
TOPICS
Acrobat SDK and JavaScript
1.1K
Translate
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
Community Expert ,
Nov 14, 2019 Nov 14, 2019

Sort the items before you add it to the listbox.

Translate
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
Community Expert ,
Nov 14, 2019 Nov 14, 2019

I cannot, items are sometimes added in several times by multiple scripts.


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
Community Expert ,
Nov 14, 2019 Nov 14, 2019

Then get the items from the listbox, sort the items, and add the items to the listbox.

Translate
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
Community Expert ,
Nov 14, 2019 Nov 14, 2019

Thank you.


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
Community Expert ,
Nov 14, 2019 Nov 14, 2019

Hi JR, here's a 30sec script

 

var oFld = this.getField("List1");
var len = oFld.numItems;
var aItems = [];
for(var i=0;i<len;i++)
     aItems.push([oFld.getItemAt(i,false),oFld.getItemAt(i,true)]);
oFld.setItems(aItems.sort())

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
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
Community Expert ,
Nov 16, 2019 Nov 16, 2019
LATEST

Thank you Thom!


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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