QuestionToolbox
An object that enables you to modify Survey Creator's Toolbox. To access this object, use the toolbox
property on a Survey Creator instance:
const creatorOptions = { ... };
const creator = new SurveyCreator.SurveyCreator(creatorOptions);
creator.toolbox.settingName = "value";
// In modular applications:
import { SurveyCreatorModel } from "survey-creator-core";
const creatorOptions = { ... };
const creator = new SurveyCreatorModel(creatorOptions);
creator.toolbox.settingName = "value";
Properties
Methods
Events
Gets or sets the currently expanded category. Applies only if allowExpandMultipleCategories
and keepAllCategoriesExpanded
are false
and showCategoryTitles
is true
.
Default value: ""
- Type:
- string readonly
- Implemented in:
- QuestionToolbox
- See also:
- expandCategory * , collapseCategory
Adds a new item to the Toolbox.
- Type:
- (item: IQuestionToolboxItem, index?: number) => void
- Parameters:
-
index, type: number ,
(Optional) A zero-based index at which to insert the item. If you do not specify this parameter, the item is added to the end.
- Implemented in:
- QuestionToolbox
- See also:
- removeItem * , replaceItem * , items
Specifies whether more than one category can be in the expanded state at a time. Applies only if showCategoryTitles
is true
.
If this property is false
, the currently expanded category collapses when a user expands another category.
Default value: false
- Type:
- boolean writable
- Implemented in:
- QuestionToolbox
- See also:
- keepAllCategoriesExpanded
Contains toolbox categories and allows you to modify them.
- Type:
- any readonly
- Implemented in:
- QuestionToolbox
- See also:
- defineCategories * , showCategoryTitles
Changes the categories of multiple toolbox items.
- Type:
- (items: any) => void
- Parameters:
-
items, type: any ,
An array of objects with the following structure:
{ name: "toolboxItemName", category: "newCategoryName" }
.
- Implemented in:
- QuestionToolbox
- See also:
- defineCategories
Changes the category of a toolbox item.
- Type:
- (itemName: string, categoryName: string) => void
- Parameters:
-
categoryName, type: string ,
A new category name. Out-of-the-box category names include
"general"
,"choice"
,"text"
,"containers"
,"matrix"
, and"misc"
.
- Implemented in:
- QuestionToolbox
- See also:
- defineCategories
Removes all items from the Toolbox.
- Type:
- () => void
- Implemented in:
- QuestionToolbox
- See also:
- removeItem * , addItem * , items
Collapses all categories. Applies only if showCategoryTitles
and allowExpandMultipleCategories
are true
.
- Type:
- () => void
- Implemented in:
- QuestionToolbox
- See also:
- expandAllCategories
Collapses a category with a specified name. Applies only if showCategoryTitles
and allowExpandMultipleCategories
are true
.
- Type:
- (categoryName: string) => void
- Parameters:
-
categoryName, type: string ,
A category name. Out-of-the-box category names include
"general"
,"choice"
,"text"
,"containers"
,"matrix"
, and"misc"
.
- Implemented in:
- QuestionToolbox
- See also:
- expandCategory
Adds default items to the Toolbox. If the Toolbox contains any items before you call this method, they will be removed.
- Type:
- (supportedQuestions: any, useDefaultCategories: boolean) => void
- Parameters:
-
supportedQuestions, type: any ,
Specifies which question and panel types to include in the Toolbox.
useDefaultCategories, type: boolean ,Pass
true
if you want to create default categories.
- Implemented in:
- QuestionToolbox
Defines toolbox categories from scratch.
This method accepts an array of objects as the categories
parameter. Each object defines a single category and lists items included into it. Unlisted items can be collected in the Misc category if you pass true
as the displayMisc
parameter. Optionally, you can override display titles for individual items.
The following code defines two toolbox categories: Dropdowns and Text Input. Items that do not fall into either category are collected in Misc. The "comment"
item has a custom display title.
creator.toolbox.defineCategories([{
category: "Dropdowns",
items: [
"dropdown",
"tagbox"
]
}, {
category: "Text Input",
items: [
"text",
// Override the display title
{ name: "comment", title: "Multi-Line Input" }
]
}], true);
- Type:
- (categories: any, displayMisc?: boolean) => void
- Parameters:
-
categories, type: any ,
An array of new categories.
displayMisc, type: boolean ,Pass
true
if you want to collect unlisted toolbox items in the Misc category. Default value:false
.
- Implemented in:
- QuestionToolbox
Expands all categories. Applies only if showCategoryTitles
and allowExpandMultipleCategories
are true
.
- Type:
- () => void
- Implemented in:
- QuestionToolbox
- See also:
- collapseAllCategories
Expands a category with a specified name. Applies only if showCategoryTitles
is true
.
If allowExpandMultipleCategories
is false
, all other categories become collapsed.
- Type:
- (categoryName: string) => void
- Parameters:
-
categoryName, type: string ,
A category name. Out-of-the-box category names include
"general"
,"choice"
,"text"
,"containers"
,"matrix"
, and"misc"
.
- Implemented in:
- QuestionToolbox
- See also:
- collapseCategory
Specifies whether the Toolbox should be in compact or full mode.
Possible values:
true
- Toolbox is always in compact mode.false
- Toolbox is always in full mode.undefined
(default) - Toolbox switches between the full and compact modes automatically based on available width.
View Toolbox Customization Demo
- Type:
- boolean readonly
- Implemented in:
- QuestionToolbox
- See also:
- isCompact
Returns a toolbox item with a specified name.
- Type:
- (name: string) => QuestionToolboxItem
- Parameters:
- Return Value:
-
A toolbox item or
null
if a toolbox item with the specified name isn't found.
- Implemented in:
- QuestionToolbox
Indicates whether the Toolbox is currently in compact mode.
- Type:
- boolean readonly
- Implemented in:
- QuestionToolbox
An array of toolbox items.
- Type:
- any readonly
- Implemented in:
- QuestionToolbox
- See also:
- getItemByName * , addItem * , removeItem
Specifies whether to expand all categories without the capability to collapse any of them. Applies only if showCategoryTitles
is true
.
- Type:
- boolean writable
- Implemented in:
- QuestionToolbox
- See also:
- allowExpandMultipleCategories
Specifies how the Toolbox behaves when it contains more items than can fit on the screen.
Possible values:
"scroll"
(default) - Enables scrolling to help users reach the items that do not fit on the screen."hideInMenu"
- Hides the overflow items in a three-dot menu.
- Type:
- overflowBehaviorType readonly
- Implemented in:
- QuestionToolbox
Removes a toolbox item with a specified name.
- Type:
- (name: string) => boolean
- Parameters:
- Return Value:
-
true
if the item is successfully deleted orfalse
otherwise.
- Implemented in:
- QuestionToolbox
- See also:
- clearItems * , addItem * , items
Adds a new toolbox item and deletes an existing item with the same name (if there is any).
- Type:
- (item: IQuestionToolboxItem) => boolean
- Parameters:
- Implemented in:
- QuestionToolbox
- See also:
- addItem
Specifies whether to display a search field that allows users to find question and panel types within the Toolbox.
Default value: true
- Type:
- boolean readonly
- Implemented in:
- QuestionToolbox
Specifies whether to display category titles in the Toolbox.
Default value: false
If this property is disabled, the Toolbox hides the titles but continues to display horizontal lines that divide categories. To remove these lines as well, call the removeCategories()
method.
- Type:
- boolean writable
- Implemented in:
- QuestionToolbox
Specifies whether toolbox items support subitems.
Default value: true
- Type:
- boolean readonly
- Implemented in:
- QuestionToolbox
Copyright © 2024 Devsoft Baltic OÜ. All rights reserved.