|
Gets or sets choice items. This property accepts an array of objects with the following structure:
{
"value": any, // A unique value to be saved in the survey results.
"text": String, // A display text. This property supports Markdown. When `text` is undefined, `value` is used.
"imageLink": String // A link to the image or video that represents this choice value. Applies only to Image Picker questions.
"customProperty": any // Any property that you find useful.
}
To enable Markdown support for the text property, implement Markdown-to-HTML conversion in the onTextMarkdown event handler. For an example, refer to the following demo: Convert Markdown to HTML with Showdown.
If you add custom properties, refer to the following help topic to learn how to serialize them into JSON: Add Custom Properties to Property Grid.
If you need to specify only the value property, you can set the choices property to an array of primitive values, for example, [ "item1", "item2", "item3" ] . These values are both saved in survey results and used as display text.
- Type:
-
any[] writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- []
- Implemented in:
-
QuestionSelectBase
- See also:
-
choicesByUrl *
, choicesFromQuestion
|
|
Configures access to a RESTful service that returns choice items. Refer to the ChoicesRestful class description for more information.
View Demo
- Type:
-
ChoicesRestful writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
choices
|
|
A Boolean expression that is evaluated against each choice item. If the expression evaluates to false , the choice item becomes read-only.
A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
Use the {item} placeholder to reference the current choice item in the expression.
Refer to the following help topic for more information: Conditional Visibility.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
enableIf *
, choicesVisibleIf
|
|
Inherits choice items from a specified question. Accepts a question name.
If you specify this property, the choices , choicesVisibleIf , choicesEnableIf , and choicesOrder properties do not apply because their values are inherited.
In addition, you can specify the choicesFromQuestionMode property if you do not want to inherit all choice items.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
choicesFromQuestionMode *
, choices
|
|
Specifies which choice items to inherit from another question. Applies only when the choicesFromQuestion property is specified.
Possible values:
"all" (default) - Inherits all choice items.
"selected" - Inherits only selected choice items.
"unselected" - Inherits only unselected choice items.
Use the visibleChoices property to access inherited choice items.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- all
- Accepted values:
-
all
, selected
, unselected
- Implemented in:
-
QuestionSelectBase
- See also:
-
choicesFromQuestion *
, visibleChoices
|
|
Specifies the sort order of choice items.
Possible values:
"none" (default) - Preserves the original order of choice items.
"asc" - Sorts choice items in ascending order.
"desc" - Sorts choice items in ascending order.
"random" - Displays choice items in random order.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- none
- Accepted values:
-
none
, asc
, desc
, random
- Implemented in:
-
QuestionSelectBase
|
|
A Boolean expression that is evaluated against each choice item. If the expression evaluates to false , the choice item becomes hidden.
A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
Use the {item} placeholder to reference the current choice item in the expression.
Refer to the following help topic for more information: Conditional Visibility.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
visibleIf *
, choicesEnableIf
|
|
Empties the errors array.
- Type:
-
() => void
- Implemented in:
-
Question
- See also:
-
errors
|
|
Specifies when to clear the question value if the question becomes invisible.
Possible values:
"default" (default) - Inherits the setting from the Survey's clearInvisibleValues property.
"onHidden" - Clears the value when the question becomes invisible. If a question is invisible on startup and has an initial value, this value will be cleared when the survey is complete.
"onComplete" - Clears the value when the survey is complete.
"none" - Never clears the value of an invisible question.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- default
- Accepted values:
-
default
, none
, onComplete
, onHidden
- Implemented in:
-
Question
- See also:
-
SurveyModel.clearInvisibleValues *
, visible *
, SurveyModel.onComplete
|
|
Removes values that cannot be assigned to this question, for example, choices unlisted in the choices array.
Call this method after you assign new question values in code to ensure that they are acceptable.
This method does not remove values that do not pass validation. Call the validate() method to validate newly assigned values.
- Type:
-
() => void
- Implemented in:
-
Question
- See also:
-
validate
|
|
If the clearIncorrectValuesCallback is set, it is used to clear incorrect values instead of default behaviour.
- Type:
-
() => void readonly
- Implemented in:
-
QuestionSelectBase
|
|
Sets the question's value and comment properties to undefined .
- Type:
-
() => void
- Implemented in:
-
Question
- See also:
-
value *
, comment
|
|
Creates a new object that has the same type and properties as the current SurveyJS object.
- Type:
-
() => Base
- Implemented in:
-
Base
|
|
Get or sets the number of columns used to arrange choice items.
Set this property to 0 if you want to display all items in one line. The default value depends on the available width.
- Type:
-
number writable
- Implemented in:
-
QuestionCheckboxBase
- See also:
-
separateSpecialChoices
|
|
Collapses the survey element.
In collapsed state, the element displays only title and description .
- Type:
-
() => void
- Implemented in:
-
SurveyElement
- See also:
-
title *
, description *
, state *
, toggleState *
, expand *
, isCollapsed *
, isExpanded
|
|
Returns true if the survey element or its child elements have validation errors.
This property contains the result of the most recent validation. This result may be outdated. Call the validate method to get an up-to-date value.
- Type:
-
boolean readonly
- Implemented in:
-
SurveyElement
- See also:
-
errors
|
|
Specifies the type of content that choice items display.
Possible values:
"image" - Images in one of the following formats: JPEG, GIF, PNG, APNG, SVG, BMP, ICO.
"video" - Videos in one of the following formats: MP4, MOV, WMV, FLV, AVI, MKV.
"youtube" - Links to YouTube videos.
"auto" (default) - Selects one of the above based on the imageLink property value of each choice item.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- image
- Accepted values:
-
image
, video
- Implemented in:
-
QuestionImagePickerModel
|
|
A correct answer to this question. Specify this property if you want to create a quiz.
- Type:
-
any writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
SurveyModel.getCorrectAnswerCount *
, SurveyModel.getInCorrectAnswerCount
|
|
Returns an object in which keys are UI elements and values are CSS classes applied to them.
Use the following events of the SurveyModel object to override CSS classes:
- Type:
-
any readonly
- Implemented in:
-
SurveyElement
|
|
A default value for the question. Ignored for question types that cannot have a value (for example, HTML).
The default value is used as a question value in the following cases:
- While the survey is being loaded from JSON.
- The question is just added to the survey and does not yet have an answer.
- The respondent left the answer empty.
- Type:
-
any writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
defaultValueExpression
|
|
An expression used to calculate the defaultValue.
This expression applies until the question value is specified by an end user or programmatically.
An expression can reference other questions as follows:
{other_question_name}
{panel.other_question_name} (to access questions inside the same dynamic panel)
{row.other_question_name} (to access questions inside the same dynamic matrix or multi-column dropdown)
An expression can also include built-in and custom functions for advanced calculations. For example, if the defaultValue should be today's date, set the defaultValueExpression to "today()" , and the corresponding built-in function will be executed each time the survey is loaded. Refer to the following help topic for more information: Built-In Functions.
- Type:
-
any writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
defaultValue
|
|
Explanatory text displayed under the title.
- Type:
-
string writable
- Implemented in:
-
SurveyElementCore
- See also:
-
hasDescription
|
|
Specifies where to display a question description.
Possible values:
"default" (default) - Inherits the setting from the Survey's questionDescriptionLocation property.
"underTitle" - Displays the description under the question title.
"underInput" - Displays the description under the interactive area.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- default
- Accepted values:
-
default
, underInput
, underTitle
- Implemented in:
-
Question
- See also:
-
description *
, hasDescription
|
|
An array of choice items with which users can interact. Includes the "Select All", "Other", and "None" choice items if they are not disabled. Items are sorted according to the choicesOrder value.
- Type:
-
ItemValue[] readonly
- Implemented in:
-
QuestionSelectBase
- See also:
-
showNoneItem *
, showOtherItem *
, choicesOrder *
, choices *
, visibleChoices
|
|
A Boolean expression. If it evaluates to false , this question becomes read-only.
A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
Refer to the following help topic for more information: Conditional Visibility
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
readOnly *
, isReadOnly
|
|
Validation errors. Call the validate() method to validate survey element data.
- Type:
-
SurveyError[] writable
- Implemented in:
-
SurveyElement
- See also:
-
validate
|
|
expand
method
|
|
Expands the survey element.
- Type:
-
() => void
- Implemented in:
-
SurveyElement
- See also:
-
state *
, toggleState *
, collapse *
, isCollapsed *
, isExpanded
|
|
Moves focus to the input field of this question.
- Type:
-
(onError?: boolean) => void
- Parameters:
-
onError, type: boolean
, Pass true if you want to focus an input field with the first validation error. Default value: false (focuses the first input field). Applies to question types with multiple input fields.
- Implemented in:
-
Question
|
|
Assigns a new configuration to the current SurveyJS object. This configuration is taken from a passed JSON object.
The JSON object should contain only serializable properties of this SurveyJS object. Event handlers and properties that do not belong to the SurveyJS object are ignored.
- Type:
-
(json: any) => void
- Parameters:
-
json, type: any
, A JSON object with properties that you want to apply to the current SurveyJS object.
- Implemented in:
-
Base
- See also:
-
toJSON
|
|
Returns a display text that corresponds to the question value. For example, if you call this method for a Dropdown question, it returns an item text instead of an item value.
- Type:
-
(keysAsText: boolean, value?: any) => any
- Parameters:
-
keysAsText, type: boolean
, Applies when the question value is an object (in Matrix, Multiple Text, and similar questions). Pass true if not only values in the object should be display texts, but also keys. Default value: false .
value, type: any
, Specify this parameter to get a display text for a specific value, not for the current question value. If the question value is an object, this parameter should be a similar object.
- Implemented in:
-
Question
|
|
Returns the survey's locale.
If a default locale is used, this method returns an empty string. To get the applied locale in this case, use the following code:
import { surveyLocalization } from 'survey-core';
const defaultLocale = surveyLocalization.defaultLocale;
- Type:
-
() => string
- Implemented in:
-
SurveyElement
- See also:
-
Localization & Globalization
|
|
Returns the question value as an object in which the question name, title, value, and other parameters are stored as individual properties.
If the question can have more than one value (Matrix, Multiple Text), the object enables the isNode flag and stores information about these values in the data property. Refer to the following help topic for more information: Access Full Survey Results.
Pass an object with the includeEmpty property set to false if you want to skip empty answers.
- Type:
-
(options?: { includeEmpty?: boolean; includeQuestionTypes?: boolean; calculations?: { propertyName: string; }[]; }) => IQuestionPlainData
- Parameters:
-
options, type: { includeEmpty?: boolean; includeQuestionTypes?: boolean; calculations?: { propertyName: string; }[]; }
- Implemented in:
-
Question
|
|
Returns a JsonObjectProperty object with metadata about a serializable property that belongs to the current SurveyJS object.
If the property is not found, this method returns null .
- Type:
-
(propName: string) => JsonObjectProperty
- Parameters:
-
propName, type: string
, A property name.
- Implemented in:
-
Base
|
|
Returns the value of a property with a specified name.
If the property is not found or does not have a value, this method returns either undefined , defaultValue specified in the property configuration, or a value passed as the defaultValue parameter.
- Type:
-
(name: string, defaultValue?: any) => any
- Parameters:
-
name, type: string
, A property name.
defaultValue, type: any
, (Optional) A value to return if the property is not found or does not have a value.
- Implemented in:
-
Base
|
|
Returns title location calculated based on the question's titleLocation property and the questionTitleLocation property of the question's containers (survey, page, or panel).
- Type:
-
() => string
- Implemented in:
-
Question
- See also:
-
titleLocation *
, SurveyModel.questionTitleLocation
|
|
Returns the question type.
Possible values:
- Type:
-
() => string
- Implemented in:
-
Question
|
|
Returns true if the survey element has a description.
- Type:
-
boolean readonly
- Implemented in:
-
SurveyElementCore
- See also:
-
description
|
|
Returns false if the question has no input fields (HTML, Image, and similar question types).
- Type:
-
boolean readonly
- Implemented in:
-
Question
- See also:
-
hasSingleInput
|
|
- Type:
-
boolean readonly
- Implemented in:
-
Question
- See also:
-
hasInput
|
|
Returns false if the titleLocation property is set to "hidden" or if the question cannot have a title (for example, an HTML question).
If the title property is undefined or set to an empty string, the hasTitle property returns true , because the question uses its name as a title in this case.
- Type:
-
boolean readonly
- Implemented in:
-
Question
- See also:
-
title *
, titleLocation
|
|
Specifies whether to hide the question if no choice items are visible.
This property is useful if you show or hide choice items at runtime based on a condition.
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
|
|
Hides the question number from the title and excludes the question from numbering.
If you want to disable question numbering in the entire survey, set SurveyModel's showQuestionNumbers property to false .
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
SurveyModel.showQuestionNumbers
|
|
A value to assign to the id attribute of the rendered HTML element. A default id is generated automatically.
- Type:
-
string writable
- Implemented in:
-
Question
|
|
Specifies how to resize images or videos to fit them into their containers.
Refer to the object-fit CSS property description for information on accepted values.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- contain
- Accepted values:
-
none
, contain
, cover
, fill
- Implemented in:
-
QuestionImagePickerModel
- See also:
-
imageHeight *
, imageWidth
|
|
Specifies the height of containers for images or videos. Accepts positive numbers and CSS values.
Default value: undefined
Use the imageFit property to specify how to fit the images or videos into their containers.
- Type:
-
number writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionImagePickerModel
- See also:
-
imageWidth *
, imageFit
|
|
Specifies the width of containers for images or videos. Accepts positive numbers and CSS values.
Default value: 200
Use the imageFit property to specify how to fit the images or videos into their containers.
- Type:
-
number writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionImagePickerModel
- See also:
-
imageHeight *
, imageFit
|
|
Increases or decreases an indent of survey element content from the left edge. Accepts positive integer values and 0. Does not apply in the Default V2 theme.
- Type:
-
number writable
- Implemented in:
-
SurveyElement
- See also:
-
rightIndent
|
|
- Type:
-
boolean readonly
- Implemented in:
-
Base
|
|
Returns true if the question can display its title to the left of the input field.
- Type:
-
boolean readonly
- Implemented in:
-
Question
- See also:
-
titleLocation *
, getTitleLocation *
, hasTitle
|
|
Returns true if a question answer matches the correctAnswer property value.
View Demo
- Type:
-
() => boolean
- Implemented in:
-
Question
- See also:
-
correctAnswer *
, SurveyModel.getQuizQuestions
|
|
Returns true if the survey element is collapsed.
- Type:
-
boolean readonly
- Implemented in:
-
SurveyElement
- See also:
-
state *
, toggleState *
, collapse *
, expand *
, isExpanded
|
|
Use this method to find out if the current object is of a given typeName or inherited from it.
- Type:
-
(typeName: string) => boolean
- Parameters:
-
typeName, type: string
, One of the values listed in the getType() description.
- Implemented in:
-
Base
- See also:
-
getType
|
|
Returns true if the survey is being designed in Survey Creator.
- Type:
-
boolean readonly
- Implemented in:
-
Base
|
|
Returns true if the question value is an empty string, array, or object or if it equals undefined or null .
- Type:
-
() => boolean
- Implemented in:
-
Question
|
|
isExpanded
property
|
|
Returns true if the survey element is expanded.
- Type:
-
boolean readonly
- Implemented in:
-
SurveyElement
- See also:
-
state *
, toggleState *
, collapse *
, expand *
, isCollapsed
|
|
Returns true if a passed choice item is selected.
To obtain a choice item to check, use the noneItem or otherItem property or the choices array.
- Type:
-
(item: ItemValue) => boolean
- Parameters:
-
item, type: ItemValue
, A choice item.
- Implemented in:
-
QuestionSelectBase
- See also:
-
noneItem *
, otherItem *
, choices
|
|
Returns true if the object configuration is being loaded from JSON.
- Type:
-
boolean readonly
- Implemented in:
-
Base
|
|
Returns true if the "Other" choice item is selected.
- Type:
-
boolean readonly
- Implemented in:
-
QuestionSelectBase
- See also:
-
showOtherItem
|
|
Returns true if the survey element is a page.
- Type:
-
boolean readonly
- Implemented in:
-
SurveyElement
- See also:
-
Base.getType
|
|
Returns true if the survey element is a panel.
- Type:
-
boolean readonly
- Implemented in:
-
SurveyElement
- See also:
-
Base.getType
|
|
Returns true if a parent element (page or panel) is visible.
- Type:
-
boolean readonly
- Implemented in:
-
Question
|
|
Returns true if the survey element is a question.
- Type:
-
boolean readonly
- Implemented in:
-
SurveyElement
- See also:
-
Base.getType
|
|
Returns true if the survey element or its parent element is read-only.
If you want to switch a survey element to the read-only state based on a condition, specify the enableIf property. Refer to the following help topic for information: Conditional Visibility.
- Type:
-
boolean readonly
- Implemented in:
-
SurveyElement
- See also:
-
readOnly
|
|
Makes the question required. If a respondent skips a required question, the survey displays a validation error.
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
requiredIf *
, Data Validation
|
|
Returns true if a passed value is an empty string, array, or object or if it equals to undefined or null .
- Type:
-
(value: any, trimString?: boolean) => boolean
- Parameters:
-
value, type: any
, A value to be checked.
trimString, type: boolean
, (Optional) When this parameter is true , the method ignores whitespace characters at the beginning and end of a string value. Pass false to disable this functionality.
- Implemented in:
-
Base
|
|
Returns true if the question is visible or the survey is currently in design mode.
If you want to display or hide a question based on a condition, specify the visibleIf property. Refer to the following help topic for information: Conditional Visibility.
- Type:
-
boolean readonly
- Implemented in:
-
Question
- See also:
-
visibleIf *
, visible *
, isParentVisible
|
|
The name of a component used to render items.
- Type:
-
string writable
- Implemented in:
-
QuestionSelectBase
|
|
Specifies whether to keep values that cannot be assigned to this question, for example, choices unlisted in the choices array.
This property cannot be specified in the survey JSON schema. Use dot notation to specify it.
- Type:
-
boolean writable
- Implemented in:
-
QuestionSelectBase
- See also:
-
clearIncorrectValues
|
|
Gets or sets maximum survey element width in CSS values.
Default value: "100%" (taken from settings.maxWidth )
- Type:
-
string writable
- Implemented in:
-
SurveyElement
- See also:
-
minWidth *
, renderWidth *
, width
|
|
Gets or sets minimum survey element width in CSS values.
Default value: "300px" (taken from settings.minWidth )
- Type:
-
string writable
- Implemented in:
-
SurveyElement
- See also:
-
maxWidth *
, renderWidth *
, width
|
|
Specifies whether users can select multiple images or videos.
Default value: false
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionImagePickerModel
|
|
A survey element identifier.
Question names must be unique.
- Type:
-
string writable
- Implemented in:
-
SurveyElement
|
|
A question number or letter (depends on the questionStartIndex property of the question container (panel, page, or survey)).
When the question number, title, or the entire question is invisible, this property returns an empty string.
- Type:
-
string readonly
- Implemented in:
-
Question
- See also:
-
SurveyModel.questionStartIndex *
, hideNumber *
, titleLocation *
, visibleIf
|
|
Returns the "None" choice item. Use this property to change the item's value or text .
- Type:
-
ItemValue readonly
- Implemented in:
-
QuestionSelectBase
- See also:
-
showNoneItem
|
|
Gets or sets a caption for the "None" choice item.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
showNoneItem
|
|
An event that is raised when an ItemValue property is changed.
Parameters:
sender : this
A SurveyJS object whose property contains an array of ItemValue objects.
options.obj : ItemValue
An ItemValue object.
options.propertyName : String
The name of the property to which an array of ItemValue objects is assigned (for example, "choices" or "rows" ).
options.name : "text" | "value"
The name of the changed property.
options.newValue : any
A new value for the property.
- Type:
-
Event<(sender: Base, options: any) => any, Base, any>
- Implemented in:
-
Base
|
|
An event that is raised when a property of this SurveyJS object has changed.
Parameters:
sender : this
A SurveyJS object whose property has changed.
options.name : String
The name of the changed property.
options.newValue : any
A new value for the property.
options.oldValue : any
An old value of the property. If the property is an array, oldValue contains the same array as newValue does.
- Type:
-
EventBase<Base, any>
- Implemented in:
-
Base
|
|
An event that is raised when the question's ready state has changed (expressions are evaluated, choices are loaded from a web resource specified by the choicesByUrl property, etc.).
Parameters:
sender : SurveyModel
A survey instance that contains the question whose ready state has changed.
options.isReady : Boolean
Indicates whether the question is ready.
options.oldIsReady : Boolean
Indicates the previous ready state.
- Type:
-
EventBase<Question, any>
- Implemented in:
-
Question
|
|
Get or sets an error message displayed when users select the "Other" choice item but leave the comment area empty.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
showOtherItem
|
|
Returns the "Other" choice item. Use this property to change the item's value or text .
- Type:
-
ItemValue readonly
- Implemented in:
-
QuestionSelectBase
- See also:
-
showOtherItem
|
|
A placeholder for the comment area. Applies when the showOtherItem or showCommentArea property is true .
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
showOtherItem *
, showCommentArea
|
|
Gets or sets a caption for the "Other" choice item.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
showOtherItem
|
|
Returns a page to which the question belongs and allows you to move this question to a different page.
- Type:
-
IPage writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
|
|
Returns a survey element (panel or page) that contains the question and allows you to move this question to a different survey element.
- Type:
-
IPanel writable
- Implemented in:
-
Question
|
|
A Dynamic Panel, Dynamic Matrix, or Dropdown Matrix that includes the current question.
This property is null for standalone questions.
- Type:
-
E readonly
- Implemented in:
-
SurveyElement
|
|
The number of quiz questions. A question counts if it is visible, has an input field, and specifies correctAnswer .
- Type:
-
number readonly
- Implemented in:
-
Question
- See also:
-
Create a Quiz
, correctAnswer *
, SurveyModel.getQuizQuestions
|
|
Makes the survey element read-only.
If you want to switch a survey element to the read-only state based on a condition, specify the enableIf property. Refer to the following help topic for information: Conditional Visibility.
- Type:
-
boolean writable
- Implemented in:
-
SurveyElement
- See also:
-
isReadOnly
|
|
registerPropertyChangedHandlers
method
|
|
Registers a function to call when a property value changes.
- Type:
-
(propertyNames: string[], handler: any, key?: string) => void
- Parameters:
-
propertyNames, type: string[]
, An array of one or multiple property names.
handler, type: any
, A function to call when one of the listed properties change.
key, type: string
, (Optional) A key that identifies the current registration. If a function for one of the properties is already registered with the same key, the function will be overwritten. You can also use the key to subsequently unregister handlers.
- Implemented in:
-
Base
- See also:
-
unregisterPropertyChangedHandlers
|
|
Returns a calculated width of the rendered survey element in CSS values.
- Type:
-
string writable
- Implemented in:
-
SurveyElement
- See also:
-
width *
, minWidth *
, maxWidth
|
|
Specifies a custom error message for a required form field.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
isRequired
|
|
A Boolean expression. If it evaluates to true , this question becomes required.
A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
Refer to the following help topic for more information: Conditional Visibility
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
isRequired
|
|
Returns a character or text string that indicates a required question.
- Type:
-
string readonly
- Implemented in:
-
Question
- See also:
-
SurveyModel.requiredText *
, isRequired
|
|
Increases or decreases an indent of survey element content from the right edge. Accepts positive integer values and 0. Does not apply in the Default V2 theme.
- Type:
-
number writable
- Implemented in:
-
SurveyElement
- See also:
-
indent
|
|
Displays the "Select All", "None", and "Other" choices on individual rows.
- Type:
-
boolean readonly
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
showNoneItem *
, showOtherItem
|
|
Assigns a new value to a specified property.
- Type:
-
(name: string, val: any) => void
- Parameters:
-
name, type: string
, A property name.
val, type: any
, A new value for the property.
- Implemented in:
-
Base
|
|
Specifies whether to display labels under images or videos. Labels text are taken from the text property of each object in the choices array.
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionImagePickerModel
- See also:
-
choices
|
|
Specifies whether to display the "None" choice item.
When users select the "None" item in multi-select questions, all other items become unselected.
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
QuestionSelectBase
- See also:
-
noneItem *
, noneText
|
|
Specifies whether to display the "Other" choice item. Incompatible with the showCommentArea property.
- Type:
-
boolean writable
- Implemented in:
-
Question
- See also:
-
otherText *
, otherItem *
, otherErrorText *
, showCommentArea
|
|
Disable this property if you want to render the current question on the same line or row with the previous question or panel.
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- True
- Implemented in:
-
Question
|
|
Gets and sets the survey element's expand state.
Possible values:
"default" (default) - The survey element is displayed in full and cannot be collapsed in the UI.
"expanded" - The survey element is displayed in full and can be collapsed in the UI.
"collapsed" - The survey element displays only title and description and can be expanded in the UI.
- Type:
-
string writable
- Implemented in:
-
SurveyElement
- See also:
-
toggleState *
, collapse *
, expand *
, isCollapsed *
, isExpanded
|
|
Returns the survey object.
- Type:
-
ISurvey readonly
- Implemented in:
-
SurveyElement
|
|
A title for the survey element. If title is undefined, the name property value is displayed instead.
Empty pages and panels do not display their titles or names.
- Type:
-
string writable
- Implemented in:
-
SurveyElementCore
- See also:
-
Configure Question Titles
|
|
Sets question title location relative to the input field. Overrides the questionTitleLocation property specified for the question's container (survey, page, or panel).
Possible values:
"default" (default) - Inherits the setting from the questionTitleLocation property specified for the question's container.
"top" - Displays the title above the input field.
"bottom" - Displays the title below the input field.
"left" - Displays the title to the left of the input field.
"hidden" - Hides the question title.
Certain question types (Matrix, Multiple Text) do not support the "left" value. For them, the "top" value is used.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- default
- Accepted values:
-
default
, top
, bottom
, left
, hidden
- Implemented in:
-
Question
- See also:
-
SurveyModel.questionTitleLocation *
, getTitleLocation *
, isAllowTitleLeft
|
|
Toggles the survey element's state between collapsed and expanded.
- Type:
-
() => boolean
- Implemented in:
-
SurveyElement
- See also:
-
state *
, collapse *
, expand *
, isCollapsed *
, isExpanded
|
|
Returns a JSON object that corresponds to the current SurveyJS object.
- Type:
-
() => any
- Implemented in:
-
Base
- See also:
-
fromJSON
|
|
unregisterPropertyChangedHandlers
method
|
|
Unregisters value change event handlers for the specified properties.
- Type:
-
(propertyNames: string[], key?: string) => void
- Parameters:
-
propertyNames, type: string[]
, An array of one or multiple property names.
key, type: string
, (Optional) A key of the registration that you want to cancel.
- Implemented in:
-
Base
- See also:
-
registerPropertyChangedHandlers
|
|
Specifies whether to use display names for question values in placeholders.
Default value: true
This property applies to questions whose values are defined as objects with the value and text properties (for example, choice items in Radiogroup, Checkbox, and Dropdown questions).
You can use question values as placeholders in the following places:
- Survey element titles and descriptions
- The
html property of the HTML question
To use a question value as a placeholder, specify the question name in curly brackets: {questionName} . Refer to the following help topic for more information: Dynamic Texts - Question Values.
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- True
- Implemented in:
-
Question
|
|
Validates this question and returns false if the validation fails.
- Type:
-
(fireCallback?: boolean, rec?: any) => boolean
- Parameters:
-
fireCallback, type: boolean
, Optional. Pass false if you do not want to show validation errors in the UI.
rec, type: any
- Implemented in:
-
Question
- See also:
-
Data Validation
|
|
- Type:
-
SurveyValidator[] writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
Data Validation
|
|
Gets or sets the question value.
- Type:
-
any writable
- Implemented in:
-
Question
- See also:
-
SurveyModel.setValue *
, SurveyModel.getValue
|
|
Specifies an object property that should store the question value.
Refer to the Merge Question Values help topic for more information.
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
|
|
Gets or sets question visibility.
If you want to display or hide a question based on a condition, specify the visibleIf property. Refer to the following help topic for information: Conditional Visibility.
- Type:
-
boolean writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Default value:
- True
- Implemented in:
-
Question
- See also:
-
isVisible *
, visibleIf
|
|
An array of visible choice items. Includes the "Select All", "Other", and "None" choice items if they are visible. Items are sorted according to the choicesOrder value.
- Type:
-
ItemValue[] readonly
- Implemented in:
-
QuestionSelectBase
- See also:
-
showNoneItem *
, showOtherItem *
, choicesOrder *
, choices *
, enabledChoices
|
|
A Boolean expression. If it evaluates to false , this question becomes hidden.
A survey parses and runs all expressions on startup. If any values used in the expression change, the survey re-evaluates it.
Refer to the following help topic for more information: Conditional Visibility
- Type:
-
string writable
This property is stored in the survey JSON definition and can be edited in the Survey Creator.
- Implemented in:
-
Question
- See also:
-
visible *
, isVisible
Show More
|
|
Returns the visible index of the question in the survey. It can be from 0 to all visible questions count - 1
The visibleIndex is -1 if the title is 'hidden' or hideNumber is true
- Type:
-
number readonly
- Implemented in:
-
Question
- See also:
-
titleLocation *
, hideNumber
|
|
Sets survey element width in CSS values.
Default value: ""
- Type:
-
string writable
- Implemented in:
-
SurveyElement
- See also:
-
minWidth *
, maxWidth
|