ICustomQuestionTypeConfiguration
An interface used to create custom question types.
Refer to the following articles for more information:
Properties
Methods
Events
A function that allows you to create nested questions if you do not specify the elementsJSON
property.
- Type:
- any readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
- See also:
- elementsJSON
A function that allows you to create a custom question if you do not specify the questionJSON
property.
- Type:
- any readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
- See also:
- questionJSON
A default title for questions created with this question type. Survey authors can change the default title in the JSON object or in Survey Creator's Property Grid.
You can specify the question title with a string value or with an object that defines different titles for different locales:
import { ComponentCollection } from "survey-core";
ComponentCollection.Instance.add({
// ...
defaultQuestionTitle: "Default title"
});
// ===== OR =====
ComponentCollection.Instance.add({
// ...
defaultQuestionTitle: {
en: "Default title",
de: "Standardtitel",
fr: "Titre par défaut"
}
});
- Type:
- any readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
JSON schemas of nested questions. Specify this property to create a composite question type.
- Type:
- any readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that allows you to override the default getDisplayValue()
implementation.
- Type:
- ((keyAsText: boolean, value: any) => any) | ((question: Question) => any) readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that allows you to display different error texts based on conditions.
- Type:
- (question: Question) => string readonly
- Return Value:
-
An error text.
- Implemented in:
- ICustomQuestionTypeConfiguration
The name of an icon to use for the custom question type.
- Type:
- string readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
An array of property names to inherit from a base question or a Boolean value that specifies whether or not to inherit all properties.
Default value: false
When you create a custom specialized question type, you base it on another question type configured within the questionJSON
object. If the custom question type should inherit all properties from the base type, set the inheritBaseProps
property to true
. If you want to inherit only certain properties, set the inheritBaseProps
property to an array of their names.
Create Specialized Question Types
- Type:
- boolean | string[] readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
A name used to identify a custom question type.
- Type:
- string readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
- See also:
- title
A function that is called after the entire question is rendered.
Parameters:
question
: Question
A custom question.htmlElement
:any
An HTML element that represents the custom question.
- Type:
- (question: Question, htmlElement: any) => void
- Parameters:
-
question, type: QuestionhtmlElement, type: any
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called each time a question nested within a composite question is rendered.
Parameters:
question
: Question
A composite question.element
: Question
A nested question.htmlElement
:any
An HTML element that represents a nested question.
- Type:
- (question: Question, element: Question, htmlElement: any) => void
- Parameters:
-
question, type: Questionelement, type: QuestionhtmlElement, type: any
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called when the custom question is created. Use it to access questions nested within a composite question type.
Parameters:
question
: Question
The custom question.
- Type:
- (question: Question) => void
- Parameters:
-
question, type: Question
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called when the custom question type is initialized. Use it to add, remove, or modify the type's properties (see Override Base Question Properties).
- Type:
- () => void
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called when an ItemValue property is changed.
Parameters:
question
: Question
A custom question.options.obj
: ItemValue
AnItemValue
object.options.propertyName
:string
The name of the property to which an array ofItemValue
objects is assigned (for example,"choices"
or"rows"
).options.name
:string
The name of the changed property:"text"
or"value"
.options.newValue
:any
A new value for the property.
- Type:
- (question: Question, options: { obj: ItemValue; propertyName: string; name: string; newValue: any; }) => void
- Parameters:
-
question, type: Questionoptions, type: { obj: ItemValue; propertyName: string; name: string; newValue: any; }
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called when JSON schemas are loaded.
Parameters:
question
: Question
A custom question.
- Type:
- (question: Question) => void
- Parameters:
-
question, type: Question
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called when a custom question type property is changed. Use it to handle property changes.
Parameters:
question
: Question
A custom question.propertyName
:string
The name of the changed property.newValue
:any
A new value for the property.
- Type:
- (question: Question, propertyName: string, newValue: any) => void
- Parameters:
-
question, type: QuestionpropertyName, type: stringnewValue, type: any
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called each time a question nested within a composite question requires an update of its CSS classes.
Parameters:
question
: Question
A composite question.element
: Question
A nested question.cssClasses
:any
An object with CSS classes applied to a nested question, for example,{ root: "class1", button: "class2" }
. You can modify this object to apply custom CSS classes.
- Type:
- (question: Question, element: Question, cssClasses: any) => void
- Parameters:
-
question, type: Questionelement, type: QuestioncssClasses, type: any
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called after the question value is changed in the UI.
Parameters:
question
: Question
A custom question.name
:string
The question's name.newValue
:any
A new value for the question.
If you want to perform some actions when the value is changed in code as well as in the UI, implement the onValueSet
function.
- Type:
- (question: Question, name: string, newValue: any) => void
- Parameters:
-
question, type: Questionname, type: stringnewValue, type: any
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called before a question value is changed in the UI.
This function should return the value you want to save: newValue
, a custom value, or undefined
if you want to clear the question value.
Parameters:
question
: Question
A custom question.name
:string
The question's name.newValue
:any
A new value for the question.
- Type:
- (question: Question, name: string, newValue: any) => any
- Parameters:
-
question, type: Questionname, type: stringnewValue, type: any
- Implemented in:
- ICustomQuestionTypeConfiguration
A function that is called after the question value is set.
Parameters:
question
: Question
A custom question.newValue
:any
A new value for the question.
Unlike the onValueChanged
function, which is called only when the question value is changed in the UI, onValueSet
is called when the value is changed in code as well.
- Type:
- (question: Question, newValue: any) => void readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
A JSON schema for a built-in question type on which the custom question type is based.
Refer to the Create Specialized Question Types help topic for more information.
- Type:
- any readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
Specifies whether the custom question type is available in the Toolbox and the Add Question menu in Survey Creator.
Default value: true
Set this property to false
if your custom question type is used only to customize Property Grid content and is not meant for a survey.
- Type:
- boolean readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
A title used for this custom question type in the UI. When title
is not specified, the name
property value is used.
- Type:
- string readonly
- Implemented in:
- ICustomQuestionTypeConfiguration
- See also:
- name
Copyright © 2024 Devsoft Baltic OÜ. All rights reserved.