Documentation Docs
Documentation Docs

ICustomQuestionTypeConfiguration

An interface used to create custom question types.

Refer to the following articles for more information:

createElements property

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
createQuestion property

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
elementsJSON property

JSON schemas of nested questions. Specify this property to create a composite question type.

Type:
any readonly
Implemented in:
ICustomQuestionTypeConfiguration
getDisplayValue property

A function that allows you to override the default getDisplayValue() implementation.

Type:
((keyAsText: boolean, value: any) => any) | ((question: Question) => any) readonly
Implemented in:
ICustomQuestionTypeConfiguration
getErrorText property

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
iconName property

The name of an icon to use for the custom question type.

UI Icons

Type:
string readonly
Implemented in:
ICustomQuestionTypeConfiguration
inheritBaseProps property

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
name property

A name used to identify a custom question type.

Type:
string readonly
Implemented in:
ICustomQuestionTypeConfiguration
See also:
title
onAfterRender method

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: Question
htmlElement, 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: Question
element, type: Question
htmlElement, type: any
Implemented in:
ICustomQuestionTypeConfiguration
onCreated method

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
onInit method

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
    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: 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: Question
options, type: { obj: ItemValue; propertyName: string; name: string; newValue: any; }
Implemented in:
ICustomQuestionTypeConfiguration
onLoaded method

A function that is called when JSON schemas are loaded.

Parameters:

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: Question
propertyName, type: string
newValue, 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: Question
element, type: Question
cssClasses, 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: Question
name, type: string
newValue, 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: Question
name, type: string
newValue, type: any
Implemented in:
ICustomQuestionTypeConfiguration
onValueSet property

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.

View Demo

Type:
(question: Question, newValue: any) => void readonly
Implemented in:
ICustomQuestionTypeConfiguration
questionJSON property

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
showInToolbox property

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
title property

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.

Your cookie settings

We use cookies on our site to make your browsing experience more convenient and personal. In some cases, they are essential to making the site work properly. By clicking "Accept All", you consent to the use of all cookies in accordance with our Terms of Use & Privacy Statement. However, you may visit "Cookie settings" to provide a controlled consent.

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.