on 2022 Jan 27 11:19 AM
Hello SAC experts,
Is it possible, within script, to get a specific widget instance using only the string of the widget's name?
For example, I have an array of strings with Chart names, I loop through said array and extract all of their datasources into a datasources array.
Kind regards!
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Dear emilianogcasas,
as already mentioned, this API is documented in the Developer Handbook and in the API References 2022.2 (or later)
The example below shows how we are using it with tables and I would suggest, that it works for charts as well, you of course need to adjust it to your needs.
Create a new function similar to the screenshot below:
'var allModels' is needed to compare the model names, so that only one table for each datasource is added to the array 'OneTablePerModel'
Afterwards you can call this function like this:
var OneTableForEachModel = ArrayUtils.create(Type.Table);
OneTableForEachModel = Utils.getOneTablePerModel();
To access the value help of getWidgets API, set your cursor within the curly brackets and hit CTRL+SPACE
I hope this helps!
Best regards
Susanne
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Susanne,
Thank you for the example. My goal was to create an interface for the user to change model variables without using the standard model variables edit prompt in the toolbar.
Here's what I ended up with:
The script variable modVarMap holds the data required for the more generic function, updateModelVariables( ), to extract all the user input values from their widgets and set the model variables for their respective data sources; it's a RangeFilterValue since it has enough properties and I couldn't find another way to store a more generic object as a script variable.
I tried making a "getWidget" function but can't see how since I have to define a specific return type for it. So I have those two potentially big switches. Something else I found is that I can't store the WidgetType property in a variable and later reference it:
var oWidgetType = WidgetType.Table;
var aDataWidgetTable = Application.getWidgets({ type: oWidgetType, searchPattern: sDataWidgetName });
// getWidgets is marked as erroneous w/ message "This function has no return value."
Kind regards,
Emiliano
Yes with coming QRC1 release there's a Application.getWidgets() API with a search pattern to select widgets by name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The API reference seems to be outdated. I guess I'll have double check for methods and properties with ctrl+spacebar in the designer 😕
Thanks
User | Count |
---|---|
75 | |
30 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.