Dear SurveyJs Team,
i am stuck in a process in SuveyJs Creator and would like your support.
My business case is i want to introduce a scoring possibility per question, therefore I offer the user a checkbox per question to ask him if this question X has scoring. Questions affected should be all questions with itemvalue
choices, like dropdown, radiogroup and checkbox.
The following screenshot, shows the hasScoring
property under general settings for the question.
While this screenshot, shows the score property on the choices itemvalue level.
Moreover, this is how the json would look like:
JavaScript{
"type": "dropdown",
"Text": "Do you like Milk?",
"hasScoring": true,
"choices": [
{
"value": "Item 1",
"text": "Yes",
"score": 10
},
{
"value": "Item 2",
"text": "No",
"score": 10
},
{
"value": "Item 3",
"text": "Some",
"score": 5
}
]
}
What i want is, to show and hide score property in the choices matrix table, depending on the hasScoring
property of the question. Since hasScoring
is on a higher level, dependsOn
and visibleIf
would not work.
Moreoever, this is how i create the properties.
JavaScriptsurveyjsConfig.addProperty('question',
{
name: 'hasScoring',
type: 'boolean',
displayName: 'Has scoring?',
category: 'general',
visibleIndex: 0,
},
);
surveyjsConfig.addProperty('itemvalue',
{
name: 'score',
type: 'number',
displayName: 'Score%',
visibleIndex: 2,
},
);
I managed to show and hide the score
property on the initial state using onShowingProperty
.
JavaScriptthis.editor.onShowingProperty.add((_, options) => {
if(options.obj.getType() === 'itemvalue') {
if(options.property.name === 'score') {
options.canShow = options.parentObj.getPropertyValue('hasScoring');
}
}
});
But i am stuck and not able to make it hide and show, on value change of hasScoring
. I tried onModified
, but the canShow
option does not exist.
Looking forward to your reply.
With regards
Abdullah