settings
Global settings that apply to all surveys on the page. To specify one of the settings, use the code below:
import { settings } from "survey-core";
settings.settingName = "value";
Properties
Methods
Events
Specifies whether to animate survey elements.
Default value: true
- Type:
- boolean writable
- Implemented in:
- settings
Specifies how many milliseconds a survey should wait before it automatically switches to the next page. Applies only when auto-advance is enabled.
Default value: 300
- Type:
- number writable
- Implemented in:
- settings
One or several characters used to separate choice options in a list.
Default value: ", "
- Type:
- string writable
- Implemented in:
- settings
- See also:
- settings.itemValueSeparator
A suffix added to the name of the property that stores comments.
Default value: "-Comment"
You can specify this setting for an individual survey: commentSuffix
.
- Type:
- string writable
- Implemented in:
- settings
An object that configures string comparison.
Nested properties:
trimStrings
:boolean
Specifies whether to remove whitespace from both ends of a string before the comparison. Default value:true
.caseSensitive
:boolean
Specifies whether to differentiate between capital and lower-case letters. Default value:false
.
- Type:
- { trimStrings: boolean; caseSensitive: boolean; normalizeTextCallback: (str: string, reason: string) => string; } writable
- Implemented in:
- settings
A function that activates a proprietary SurveyJS confirm dialog.
Use the following code to execute this function:
import { settings } from "survey-core";
settings.confirmActionAsync("Are you sure?", (confirmed) => {
if (confirmed) {
// ...
// Proceed with the action
// ...
} else {
// ...
// Cancel the action
// ...
}
});
You can redefine the confirmActionAsync
function if you want to display a custom dialog window. Your function should return true
to be enabled; otherwise, a survey executes the confirmActionFunc
function. Pass the dialog result as the callback
parameter: true
if a user confirms an action, false
otherwise.
- Type:
- (message: string, callback: (res: boolean) => void, applyTitle?: string, locale?: string, rootElement?: HTMLElement) => boolean writable
- Parameters:
-
message, type: string ,
A message to be displayed in the confirm dialog window.
callback, type: (res: boolean) => void ,A callback function that should be called with
true
if a user confirms an action orfalse
otherwise.applyTitle, type: stringlocale, type: stringrootElement, type: HTMLElement
- Implemented in:
- settings
A function that activates a browser confirm dialog.
Use the following code to execute this function:
import { settings } from "survey-core";
// `result` contains `true` if the action was confirmed or `false` otherwise
const result = settings.confirmActionFunc("Are you sure?");
You can redefine the confirmActionFunc
function if you want to display a custom dialog window. Your function should return true
if a user confirms an action or false
otherwise.
- Type:
- (message: string) => boolean writable
- Parameters:
-
message, type: string ,
A message to be displayed in the confirm dialog window.
- Implemented in:
- settings
An object that specifies icon replacements. Object keys are built-in icon names. To use a custom icon, assign its name to the key of the icon you want to replace:
import { settings } from "survey-core";
settings.customIcons["icon-redo"] = "custom-redo-icon";
For more information about icons in SurveyJS, refer to the following help topic: UI Icons.
- Type:
- {} writable
- Implemented in:
- settings
An object that configures survey appearance when the survey is being designed in Survey Creator.
Nested properties:
showEmptyDescriptions
:boolean
Specifies whether to display an empty description for pages and panels. Default value:true
.showEmptyTitles
:boolean
Specifies whether to display an empty title for pages and panels. Default value:true
.
- Type:
- { showEmptyDescriptions: boolean; showEmptyTitles: boolean; } writable
- Implemented in:
- settings
A value to save in survey results when respondents select the "Don't know" choice item.
Default value: "dontknow"
- Type:
- string writable
- Implemented in:
- settings
A time interval in milliseconds between the last entered character and the beginning of search in Single- and Multi-Select Dropdown questions. Applies only to questions with the choicesLazyLoadEnabled
property set to true
.
Default value: 500
- Type:
- number writable
- Implemented in:
- settings
Specifies an action to perform when users press the Enter key within a survey.
Possible values:
"moveToNextEditor"
- Moves focus to the next editor."loseFocus"
- Removes focus from the current editor."default"
- Behaves as a standard<input>
element.
- Type:
- "moveToNextEditor" | "loseFocus" | "default" writable
- Implemented in:
- settings
A separator used in a shorthand notation that specifies a value and display text for an ItemValue
object: "value|text"
.
Default value: "|"
- Type:
- string writable
- Implemented in:
- settings
- See also:
- settings.choicesSeparator
An object that configures lazy rendering.
Nested properties:
enabled
:boolean
Specifies whether to add questions to the DOM only when they get into the viewport. Default value:false
.
- Type:
- { enabled: boolean; firstBatchSize: number; } writable
- Implemented in:
- settings
- See also:
- SurveyModel.lazyRendering
An object that contains properties related to localization.
Nested properties:
useLocalTimeZone
:boolean
Disable this property if you want internal SurveyJS functions to use methods that work with UTC date and time (setUTCDate()
setUTCHours()
, etc.) instead of methods that work with local date and time (setYear()
,setHours()
, etc.). Default value:true
.defaultLocaleName
:string
A property key that stores a translation for the default locale. Default value:"default"
.storeDuplicatedTranslations
:boolean
Specifies whether surveys should store translation strings that equal the translation strings in the default locale. Default value:false
.
- Type:
- { useLocalTimeZone: boolean; storeDuplicatedTranslations: boolean; defaultLocaleName: string; } writable
- Implemented in:
- settings
An object with properties that configure input masks.
Nested properties:
patternPlaceholderChar
:string
A symbol used as a placeholder for characters to be entered in pattern masks. Default value:"_"
.patternEscapeChar
:string
A symbol used to insert literal representations of special characters in pattern masks. Default value:"\\"
.patternDefinitions
:<{ [key: string]: RegExp }>
An object that maps placeholder symbols to regular expressions in pattern masks. Default value:{ "9": /[0-9]/, "a": /[a-zA-Z]/, "#": /[a-zA-Z0-9]/ }
.
- Type:
- { patternPlaceholderChar: string; patternEscapeChar: string; patternDefinitions: { [key: string]: RegExp; }; } writable
- Implemented in:
- settings
An object with properties that apply to Single-Choice, Multiple-Choice, and Dynamic Matrix questions.
Nested properties:
defaultRowName
:string
A property key that stores an object with default cell values. Default value: "default".defaultCellType
:string
The default type of matrix cells. Default value:"dropdown"
.
You can specify this setting for individual questions or matrix columns:cellType
. Refer to thecellType
property description for information on possible values.totalsSuffix
:string
A suffix added to the name of the property that stores total values. The resulting property name consists of the matrix name and the suffix. Default value:"-total"
.maxRowCount
:number
A maximum number of rows in a Dynamic Matrix. Default value: 1000.
You can specify this setting for an individual Dynamic Matrix:maxRowCount
.maxRowCountInCondition
:number
A maximum number of matrix rows included in the Condition drop-down menu in Survey Creator. This menu is used to configure conditional survey logic. Default value: 1.
If you set this property to 0, the Condition menu does not include any matrix rows. Users still can specify conditions that use matrix rows but only with Manual Entry.renderRemoveAsIcon
:boolean
Disable this property if you want to render the Remove action in Dynamic Matrix as a button. Otherwise, the action is rendered as an icon. Default value:true
.columnWidthsByType
:object
An object that specifies fixed and minimum column width based on the column type.
Example:settings.matrix.columnWidthsByType = { "tagbox": { minWidth: "240px", width: "300px" } }
rateSize
:"small"
(default) |"normal"
Specifies the size of rate values. Applies to Rating Scale questions within matrixes.
- Type:
- { defaultCellType: string; defaultRowName: string; totalsSuffix: string; maxRowCount: number; maxRowCountInCondition: number; renderRemoveAsIcon: boolean; columnWidthsByType: { [index: string]: { minWidth?: string; width?: string; }; }; rateSize: "small" | "normal"; } writable
- Implemented in:
- settings
Specifies how many times surveys can re-evaluate expressions when a question value changes. This limit helps avoid recursions in expressions.
Default value: 10
- Type:
- number writable
- Implemented in:
- settings
A value to save in survey results when respondents select the "None" choice item.
Default value: "none"
- Type:
- string writable
- Implemented in:
- settings
An object that configures notifications.
Nested properties:
lifetime
:number
Specifies a time period during which a notification is displayed; measured in milliseconds. Default value: 2000.
- Type:
- { lifetime: number; } writable
- Implemented in:
- settings
An object with properties that configure question numbering.
Nested properties:
includeQuestionsWithHiddenNumber
:boolean
Specifies whether to number questions whosehideNumber
property is enabled. Default value:false
.includeQuestionsWithHiddenTitle
:boolean
Specifies whether to number questions whosetitleLocation
property is set to"hidden"
. Default value:false
.
- Type:
- { includeQuestionsWithHiddenNumber: boolean; includeQuestionsWithHiddenTitle: boolean; } writable
- Implemented in:
- settings
An object with properties that apply to Dynamic Panel questions.
Nested properties:
maxPanelCount
:number
A maximum number of panels in Dynamic Panel. Default value: 100.
You can specify this setting for an individual Dynamic Panel:maxPanelCount
.maxPanelCountInCondition
:number
A maximum number of Dynamic Panel panels included in the Condition drop-down menu in Survey Creator. This menu is used to configure conditional survey logic. Default value: 1.
If you set this property to 0, the Condition menu does not include any panel questions. Users still can specify conditions that use panel questions but only with Manual Entry.
- Type:
- { maxPanelCount: number; maxPanelCountInCondition: number; } writable
- Implemented in:
- settings
A function that allows you to define custom parsing rules for numbers represented as string values.
The following code shows a template that you can use to implement the parseNumber
function:
import { settings } from "survey-core";
settings.parseNumber = (stringValue, numericValue) => {
if (typeof stringValue !== "string" || !stringValue)
return numericValue;
let parsedNumber = numericValue;
// ...
// Parsing the number according to custom parsing rules
// ...
return parsedNumber;
};
- Type:
- (stringValue: any, numericValue: number) => number writable
- Return Value:
-
A number that results from parsing the string value.
- Implemented in:
- settings
- See also:
- settings.serialization
Specifies which part of a choice item responds to a drag gesture in Ranking questions.
Possible values:
"entireItem"
(default) - Users can use the entire choice item as a drag handle."icon"
- Users can only use the choice item icon as a drag handle.
- Type:
- string writable
- Implemented in:
- settings
An object with properties that configure questions in read-only mode.
Nested properties:
commentRenderMode
:"textarea"
(default) |"div"
Specifies how to render the input field of Comment questions in read-only mode: as a disabled<textarea>
element or as a<div>
element with a non-editable question value within it.textRenderMode
:"input"
(default) |"div"
Specifies how to render the input field of Text questions in read-only mode: as a disabled<input>
element or as a<div>
element with a non-editable question value within it.
- Type:
- { enableValidation: boolean; commentRenderMode: string; textRenderMode: string; } writable
- Implemented in:
- settings
A value to save in survey results when respondents select the "Refuse to answer" choice item.
Default value: "refused"
- Type:
- string writable
- Implemented in:
- settings
An object that contains properties related to JSON serialization.
Nested properties:
itemValueSerializeAsObject
:boolean
Enable this property if you want to serializeItemValue
instances as objects even when they include only thevalue
property. Default value:false
. View an example below.itemValueSerializeDisplayText
:boolean
Enable this property if you want to serialize thetext
property ofItemValue
objects even when it is empty or equal to thevalue
property. Default value:false
. View an example below.localizableStringSerializeAsObject
:boolean
Enable this property if you want to serializeLocalizableString
instances as objects even when they include only a translation string for the default locale. For example,"Custom String"
will be serialized as{ default: "Custom String" }
. Default value:false
.
import { ItemValue, settings } from "survey-core";
// `itemValueSerializeAsObject` example
settings.serialization.itemValueSerializeAsObject = true;
const item = new ItemValue(5);
const itemString = item.toJSON(); // Produces { value: 5 } instead of 5
// `itemValueSerializeDisplayText` example
settings.serialization.itemValueSerializeDisplayText = true;
const item = new ItemValue("item1");
const itemString = item.toJSON(); // Produces { value: "item1", text: "item1" } instead of "item1"
- Type:
- { itemValueSerializeAsObject: boolean; itemValueSerializeDisplayText: boolean; localizableStringSerializeAsObject: boolean; } writable
- Implemented in:
- settings
- See also:
- settings.parseNumber
Specifies the direction in which to lay out Checkbox and Radiogroup items. This setting affects the resulting UI when items are arranged in more than one column.
Possible values:
"row"
(default) - Items fill the current row, then move on to the next row."column"
- Items fill the current column, then move on to the next column.
- Type:
- string writable
- Implemented in:
- settings
Allows you to hide the maximum length indicator in text input questions.
If you specify a question's maxLength
property or a survey's maxTextLength
property, text input questions indicate the number of entered characters and the character limit. Assign false
to the settings.showMaxLengthIndicator
property if you want to hide this indicator.
Default value: true
- Type:
- boolean writable
- Implemented in:
- settings
An object whose properties specify the order of the special choice items ("None", "Other", "Select All", "Refuse to answer", "Don't know") in select-based questions.
Default value: { selectAllItem: [-1], noneItem: [1], otherItem: [2], dontKnowItem: [3], otherItem: [4] }
Use this object to reorder special choices. Each property accepts an array of integer numbers. Negative numbers place a special choice item above regular choice items, positive numbers place it below them. For instance, the code below specifies the following order of choices: None, Select All, regular choices, Other.
import { settings } from "survey-core";
settings.specialChoicesOrder.noneItem = [-2];
settings.specialChoicesOrder.selectAllItem = [-1];
settings.specialChoicesOrder.otherItem = [1];
If you want to duplicate a special choice item above and below other choices, add two numbers to the corresponding array:
settings.specialChoicesOrder.selectAllItem = [-1, 3] // Displays Select All above and below other choices
- Type:
- { selectAllItem: number[]; noneItem: number[]; refuseItem: number[]; dontKnowItem: number[]; otherItem: number[]; } writable
- Implemented in:
- settings
Specifies whether to store date-time values in the following format: "YYYY-MM-DDThh:mm:ss.sssZ"
. Applies only to form fields with inputType
set to "datetime-local"
.
Default value: false
If you enable this setting, date-time values are converted from local time to UTC when they are saved to the survey's data
object, while the question values remain in local time. Therefore, when you specify default values using a question's defaultValue
property, you need to use local time, but if you specify them using the data
object, use a UTC date-time value in the following format: "YYYY-MM-DDThh:mm:ss.sssZ"
.
const surveyJson = {
"elements": [{
"name": "datetime",
"type": "text",
"title": "Select a date and time",
"inputType": "datetime-local",
"defaultValue": "2024-07-16T12:15:00" // Local date-time value
}]
}
import { Model } from "survey-core";
const surveyJson = { ... }
const survey = new Model(surveyJson);
survey.data = {
datetime: "2024-07-16T12:15:00.000Z" // UTC date-time value
}
- Type:
- boolean writable
- Implemented in:
- settings
A list of supported validators by question type.
- Type:
- { question: string[]; comment: string[]; text: string[]; checkbox: string[]; imagepicker: string[]; } writable
- Implemented in:
- settings
Specifies whether to close the drop-down menu of a Multi-Select Dropdown (Tag Box) question after a user selects a value.
This setting applies to all Multi-Select Dropdown questions on a web page. You can use the closeOnSelect
property to specify the same setting for an individual Multi-Select Dropdown question.
- Type:
- boolean writable
- Implemented in:
- settings
An object that specifies heading levels (<h1>
, <h2>
, etc.) to use when rendering survey, page, panel, and question titles.
Default value: { survey: "h3", page: "h4", panel: "h4", question: "h5" }
If you want to modify heading levels for individual titles, handle SurveyModel
's onGetTitleTagName
event.
- Type:
- { survey: string; page: string; panel: string; question: string; } writable
- Implemented in:
- settings
An object that contains properties related to triggers.
Nested properties:
changeNavigationButtonsOnComplete
:boolean
Specifies whether to re-evaluate an expression associated with the Complete trigger immediately when a question value changes. If the expression evaluates totrue
, the trigger is executed. Default value:false
.
Keep this property set tofalse
if you want to re-evaluate the Complete trigger's expression only when the respondents navigate to another page.executeCompleteOnValueChanged
:boolean
Specifies whether to replace the Next button with the Complete button when the Complete trigger is going to be executed. Default value:true
.executeSkipOnValueChanged
:boolean
Specifies whether to re-evaluate an expression associated with the Skip trigger immediately when a question value changes. If the expression evaluates totrue
, the trigger is executed. Default value:true
.
Disable this property if you want to re-evaluate the Skip trigger's expression only when respondents navigate to another page.
- Type:
- { changeNavigationButtonsOnComplete: boolean; executeCompleteOnValueChanged: boolean; executeSkipOnValueChanged: boolean; } writable
- Implemented in:
- settings
An object with properties that configure surveys when they work with a web service.
Nested properties:
encodeUrlParams
:boolean
Specifies whether to encode URL parameters when you access a web service. Default value:true
.cacheLoadedChoices
:boolean
Specifies whether to cache choices loaded from a web service. Default value:true
.disableQuestionWhileLoadingChoices
:boolean
Disables a question while its choices are being loaded from a web service. Default value:false
.surveyServiceUrl
:string
The URL of the SurveyJS Service API endpoint.onBeforeRequestChoices
:(sender: ChoicesRestful, options: { request: XMLHttpRequest })
An event that is raised before a request for choices is send. Applies to questions with a specifiedchoiceByUrl
property. Use theoptions.request
parameter to access and modify theXMLHttpRequest
object. For instance, you can add authentication headers to it:import { settings } from "survey-core"; settings.web.onBeforeSendRequest = (sender, options) => { options.request.setRequestHeader('RequestVerificationToken', requestVerificationToken); };
- Type:
- { onBeforeRequestChoices: (sender: any, options: { request: any; }) => void; encodeUrlParams: boolean; cacheLoadedChoices: boolean; disableQuestionWhileLoadingChoices: boolean; surveyServiceUrl: string; } writable
- Implemented in:
- settings
Copyright © 2024 Devsoft Baltic OÜ. All rights reserved.