Skip to main content
Participating Frequently
September 1, 2020
Question

Need a little direction on how to group multiple objects using JavaScript?

  • September 1, 2020
  • 2 replies
  • 1017 views

I would like to group multiple comments together using JavaScript.  I can do it manually - select objects, right-click, group - but cannot find any data on how to do it using JavaScript.  I would be appreciative if anyone could point me in the right direction on this.

 

I am aware of the current issue with grouped objects not staying together when being moved, but I still need to use the functionality.

 

Thanks!

Nick

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
September 1, 2020

Assuming this is static contents, it's not possible. If it's not, please specify what kind of "objects" you're referring to.

ls_rbls
Community Expert
Community Expert
September 1, 2020

Are the sticky notes considered static content?

 

I'm noticing that you're not even able to cut, copy , or paste them even using the GUI method; just select and drag them around in the same page.

 

 

try67
Community Expert
Community Expert
September 1, 2020

No, sticky notes are comments (annotations). You should be able to cut, copy and paste them. Maybe they're locked, or you're selecting the text popup instead of the comment itself...

You can't drag them across pages, though. For that you have to cut and paste them.

Joel Geraci
Community Expert
Community Expert
September 1, 2020

The JavaScript API doesn't support grouping. What exactly are you trying to accomplish, there might be a different way to approach the problem.

ls_rbls
Community Expert
Community Expert
September 1, 2020

Hey Joel, would something like this work:

 

 

var annots = this.getAnnots({nPage:0,});  // if working on page 1 (0-based index)
annots.page = 2;   //move all annotations to page 3

or 

annots.pageNum++;    // to move to the next page

 

 

If you want to get a specific group of annotations  you will need to specify by author, type , or creation date.

 

The example above just grabs all annotations found in the specified page.

Joel Geraci
Community Expert
Community Expert
September 1, 2020

Your code is off but you're on the right track. If the goal is to move a set of selected annotations to a different page, you'd use this.selectedAnnots to get the annotation array of selected annotations but then you'd need to loop through each one and set the page parameter. You can't just set it from the array.