Survey Creator Toolbox Categories
The Toolbox is a UI element that displays available question and panel types. To add a question or panel to your survey, simply click it in the Toolbox or drag and drop the desired survey element onto the design surface. This example shows how to arrange questions and panels in the Toolbox into multiple categories.
Note that the Toolbox displays categories only in full display mode. This mode is enabled automatically when Survey Creator has sufficient width. If you want to use the full mode at all times, set the forceCompact
property to false
.
Define Toolbox Categories
To organize toolbox items into categories, use the defineCategories(categories, displayMisc)
method. 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. Refer to the defineCategories
method call in the code for an example.
You can also use localization capabilities to change the caption of the Misc category. This demo shows how to rename the Misc category to "Other Questions". Note that the code that changes the caption should go before the code that instantiates Survey Creator.
Display Category Titles
Toolbox categories do not show their titles by default. Instead, the categories are separated one from another by a delimiter. If you want to display category titles, enable Toolbox's showCategoryTitles
property.
Reorder Categories
Created categories are stored in the categories
array of the Toolbox. You can access and modify this array if you want to reorder categories at runtime.
Control the Behavior
The Toolbox also has the following properties to control the behavior of categories:
allowExpandMultipleCategories
Allows users to expand more than one category at a time. If this property isfalse
, the currently expanded category collapses when a user expands another category.keepAllCategoriesExpanded
Expands all categories. Users cannot collapse them.
Since these two properties are incompatible with each other, this example demonstrates only the allowExpandMultipleCategories
property.