Hi Team,
Can I know how to disable a Name field of a question?
Thanks and Regards,
Santosh
Hi Team,
Can I know how to disable a Name field of a question?
Thanks and Regards,
Santosh
[Updated]
You can run the following code to set a name
property read-only:
JavaScriptimport { Serializer } from "survey-core";
Serializer.findProperty("question", "name").readOnly = true;
Please refer to the following example on our website: Modify New Question.
To set a property read-only for specific questions, handle the creator.onGetPropertyReadOnly function. The following code disables the name
property for all Radiogroup questions:
CodeJavaScriptcreator.onGetPropertyReadOnly.add(function(sender, options){
options.readOnly = options.obj.getType() === 'radiogroup' && options.propertyName === 'name';
});
Hi Santosh,
With the creator.onGetPropertyReadOnly function, you can disable any property as per your needs dictate.
Consider the following code. It disables the name
property for all Radiogroup questions:
JavaScriptcreator.onGetPropertyReadOnly.add(function(sender, options){
options.readOnly = options.obj.getType() === 'radiogroup' && options.propertyName === 'name';
});
Please let me know if this code can help you.
Hi Jane,
Working as expected. Thank you for the quick response.
Thanks and Regards,
Santosh
You're always welcome, Santosh.
Please feel free to contact us if you have any questions or require further assistance.