Hi everyone,
Is there a simple way to get all types of objects (objects that I already store in "objdefs") and show them in checkboxes ? (I don't want to use a listbox because I need to let the user have a multiple choice).
how I store my objects :
var loc = Context.getSelectedLanguage();
var group = ArisData.getSelectedGroups()[0];
//stocker tous les modèles
var grpMdls = ArisData.getSelectedGroups()[0].ModelList(true);
//récupérer tous les objets des modèles
var objdefs = new Array();
for(var i = 0; i < grpMdls.length; i++){
objdefs = objdefs.concat(grpMdls[i].ObjDefList());
}
Thank you in advance !
Hi
may I ask what's wrong with giving the user a ListBox for multiple choice?
While it does not support multiple choice by default, if your last parameter is 1 (supports multi-select) or 2 (sorted + supports multi-select) users will be able to select multiple items. Controls are similar to what you'd find in a file explorer - hold ctrl and click on entries to toggle their individual selection, or click on one item, hold shift and click on another item to select a range of items (first clicked item + last clicked item + everything in between).
iDialogTemplate1.ListBox(10, 20, 100, 80, objDefStringNameArray, "LISTBOX_1", 1);
***
How to get the Object defs actually into the list? Don't think there is a way other than creating a string array with the object def names. That's fairly easy - and would be even easier if the ArisScript engine would comply with the EMCA2015 standard (or newer) giving us access to arrow functions - but sadly it does not support that, so you'll have to do something like
var nLocale = Context.getSelectedLanguage();
var objDefStringNameArray = objdefs.map(mapObjDefToString);
function mapObjDefToString(anObjDef) {
return anObjDef.Name(nLocale);
}
The order of objects is retained throughout the mapping process, so when your dialog returns that the usere selected string element 2, 5 and 8 you can easily look up in your original array which objectdefs are at index position 2, 5 and 8.
Hope this helps.
Thank you Kay Fischbach for your answer.
This works ! Also, I don't know how to catch the multiple selection, I tried this
var listBoxObject = this.dialog.getDialogElement("LISTBOX_1");
var currSelectionIndex = listBoxObject.getSelectedIndex();
but this return just the first element selected. How can I get them all ?
Thanks !
Noémie
Oh, you used .getSelectedIndex() of the SingleSelectElement interface.
ListBox actually also implements the MultiSelectElement interface, which has a method called .getSelection() that returns an array of integers - the index numbers of the selected elements.
var listBoxObject = this.dialog.getDialogElement("LISTBOX_1");
var currSelectionIndexes = listBoxObject.getSelection();
should give you what you're looking for.