Hello new to using select2 so apologize ahead of time.
I am using version 3.5.3 of select2 in my application
My objects are different as shown in the debugger and I am trying to get this work. I know I can reformat the data using formatResult or data but not quite sure how to.
Here are my two objects from the debugger:
secretarialOrderSubtypes:
secretarialOrder.secretarialOrderSubtypes:
(2) [{…}, {…}]
0: class: “gov.doi.fws.habits.SecretarialOrderSubtypeLut”
id: 1
isActive: true
labelName: “Big-Game Species”
name: “Rocky Mountain Elk (elk)”
sortOrder: 0
validSoTypeId: 2
proto: Object
1: class: “gov.doi.fws.habits.SecretarialOrderSubtypeLut”
id: 2
isActive: true
labelName: “Big-Game Species”
name: “Mule Deer (deer)”
sortOrder: 0
validSoTypeId: 2
proto: Objectlength: 2__proto__: Array(0)
I would like to do the following in javascript:
$("#secretarialOrderSubtypes").select2(“val”, secretarialOrder.secretarialOrderSubtypes);
But since they are different objects I am getting selected items I want using:
<g:select class=“form-control”
name=“secretarialOrderSubtypes”
id=“secretarialOrderSubtypes”
noSelection="${[‘null’:‘Select…’]}"
from="${secretarialOrderSubtypeOptions}"
optionKey=“id”
optionValue=“name”
required=“true”
multiple=“true”
/>
Hoping this makes sense and I did not leave out any detail that is needed.