Widget extension - how to dynamically add EVENTS to a widget
Hi all,
i'm trying to create a widget that has to deal with N inputs.
Each input needs an EVENT, that will be fired if the binded input its selected.
The problem arises here, in Thingworx you can't add dynamically properties, but you can declare them in the "widgetProperties" function with "isVisible" attribute, and set/unset it. (and it worst as expected) :
mdfork.ide.js
this.widgetProperties = function () {
var properties = {
'name': 'mdfork',
'description': '',
'category': ['Common', 'MD-Components'],
'defaultBindingTargetProperty': 'Value',
'properties':{
'icon':{
'defaultValue': 'share',
'isEditable': true,
'baseType': 'STRING'
},
'comparablesNumber': {
'description': 'Aumenta questo valore per aggiungere altri slot di comparazione',
'baseType': 'NUMBER',
'defaultValue': this.prevComparablesNumber,
'isBindingTarget': true,
'isVisible': true
},
'CustomClass': {
'description': '',
'baseType': 'STRING',
'isLocalizable': false,
'isBindingSource': true,
'isBindingTarget': true,
'isVisible': false
},
'visible':{
'defaultValue': 'block',
'isEditable': true,
'baseType': 'STRING'
},
'Disabled': {
'baseType': 'BOOLEAN',
'defaultValue': false,
'isBindingTarget': true
}
}
}
for(var i=1; i<=MAX_COMPARABLES_NUMBER; i++){
properties.properties['compareValue_' + i] = {
'description': 'Valore di input, da confrontare con i compareValues',
'baseType': 'STRING',
'isBindingTarget': true,
'defaultValue': '',
'isEditable': true,
'isVisible': false
};
}
return properties;
};
In the same way, I tried to do with Events, but Events doesn't expose a "isVisible" attribute, so if i change the number of inputs, the events number doesn't scale as expected.
How can I achieve this?
Thanks!

