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

Sorting data in a pdf form

Community Beginner ,
Mar 25, 2019 Mar 25, 2019

I have a pdf form with rows and columns of data. I am looking for a solution for when the data comes in and is not in numerical order. I would like to be able to sort the data in the form based on a value in a column of data named 'outlets.0', 'outlets.1', etc. All associated rows have the same ending value (.....'.0') so I should be able to group the data together. I can use a button to call a javascript action. I have many functions in the form already but I'm not certain on where to even begin with this one. Will I need to

- loop through the rows, and pull the data into a hash

- make the key of the hash the column (hashes can be sorted by their keys in Perl, so I assume it’s the same)

- redistribute the data into the rows

or would there be a more simple way?

TOPICS
PDF forms
5.7K
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 ,
Mar 25, 2019 Mar 25, 2019

The second step you described is not how it's done in JavaScript. You will need to write a custom sort function and then call the sort method of the Array object you've created in the first step to sort it according to your desired parameters.

The rest is pretty much as you've written. The only thing that's missing is deciding what should trigger this operation. You say "when the data comes in" but that's pretty vague. Is this data being imported into the file? Entered by the user? Calculated automatically? Something else?

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 Beginner ,
Mar 25, 2019 Mar 25, 2019

Will the values need to be stored temporarily before it can be sorted? The data is being entered by the user and is sent in for review. I am fine with initializing the function with a manual function button once the review is complete.

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 ,
Mar 25, 2019 Mar 25, 2019
LATEST

Yes, you'll have to save the data into an in-memory array variable to be able to sort it.

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