Overview

Nancy Davolio (Sales Representative)

The TagBox is an editor that allows users to select multiple items (tags) from a predefined drop-down list. Users can also type in the edit box to filter list items that contain the search string.

The main TagBox API members are listed below:

  • Data — Specifies the data source that populates the editor's list items.
  • TextFieldName — Specifies the data source's field that supplies text for items.
  • Tags — Specifies the editor's tags.
  • TagsChanged — Fires when the tag collection is changed.
  • Values — Specifies the drop-down list's selected values.
  • ValuesChanged — Fires when the selected value collection is changed.

The TagBox component supports different size modes. To specify the component's size in code, use the SizeMode property. To apply different size modes, use the drop-down list in the demo card's header.

The TagBox supports keyboard navigation (list of supported keyboard shortcuts), allowing users to navigate within the item list and select tags.

This demo illustrates how to bind the TagBox to a list of complex business objects.

Custom Tags

London
New York

In this demo, the TagBox supports custom tags that are not stored in a bound data source (the AllowCustomTags property is set to true).

Item Values

Nancy Davolio (Sales Representative)
Andrew Fuller (Vice President, Sales)

Selected Values: ( 1, 2 )

The TagBox component provides access to item values. The value is assigned to the editor's edit value when a user selects an item from the drop-down list. To enable this access, set the ValueFieldName property to the name of the data source field that ships with values for the TagBox items.

If the ValueFieldName property is not specified, the TagBox component searches for a Value field in the data source and uses this field as a value field. Otherwise, values are not assigned to editor items.

To access values of the selected items, use the Values property. To track selection changes, use the ValuesChanged event or two-way synchronization as demonstrated in this module.

Multiple Columns

Nancy Davolio

Our Blazor TagBox can display data across multiple columns. To create columns, use DxListEditorColumn objects as needs dictate. Objects include the following column customization options:

  • Caption — Specifies the column caption.
  • FieldName — Specifies the data source field used to populate column items.
  • SearchEnabled — Specifies whether the component can search text in cells associated with the current column.
  • Visible — Specifies column visibility.
  • VisibleChanged — Fires when column visibility changes.
  • VisibleIndex — Specifies column display order.
  • VisibleIndexChanged — Fires when the column's visible index changes.
  • Width — Specifies column width.

To format an editor value, use the EditFormat property. This property allows you to format values displayed in both standard and multi-column TagBoxes. A {0} {1} format specifies that the editor value includes values for the following columns: FirstName (VisibleIndex = 0) and LastName (VisibleIndex = 1).

Clear Button and Placeholder

This demo illustrates how to use the NullText property to display placeholder text in the TagBox when its value is null.

Set the ClearButtonDisplayMode property to Auto to display the Clear button when the TagBox has a non-null value. Users can click this button to clear the editor's value (set it to null).

Virtual Scrolling

Aachen

Use the ListRenderMode property to specify how the TagBox renders the item list.

  • Entire — The TagBox renders the entire item list. Use this option for small item lists where scrolling should work instantly.
  • Virtual — The TagBox renders items only after they appear in the viewport. Use this option to improve performance when the list contains to many items to render simultaneously.

In this demo, the ListRenderMode property is set to ListRenderMode.Virtual.

Search and Filter Data

UK
USA

Our Blazor TagBox allows you to introduce search and filter capabilities via the following API members:

  • SearchMode — Specifies whether the component can search for text based on user input (within the edit box).
  • SearchFilterCondition — Specifies the search and filter condition (Contains or StartsWith).
  • SearchTextParseMode — Specifies how the component treats search words. If search text contains multiple words separated by space characters, words can be treated as a single condition or individual conditions. The following text parse modes are available: GroupWordsByAnd, GroupWordsByOr, and ExactMatch.

For additional information, refer to the following topic: Search and Filter Data.

Nancy
Nancy Davolio (Sales Representative)

Use the DropDownWidthMode property to specify the width of a drop-down list.

  • ContentOrEditorWidth (Default) — The list's width is equal to the width of the longest list item or the editor's width (whichever is larger).
  • ContentWidth — The list's width is equal to the width of the longest list item.
  • EditorWidth — The list's width is equal to the editor's width. List items are cut if they do not fit.

In this demo, ContentOrEditorWidth mode is used for both TagBox components. To change the width of their drop-down lists, use the Drop Down Width Mode option below.

Show/Hide Selected Items

Los Angeles
New York

In this demo, the TagBox displays selected items in the drop-down list. Set the HideSelectedItems property to false to enable this behavior.

Tag Display Template

This demo uses the TagDisplayTemplate property to customize tag's appearance.

The template's Context parameter has the following properties:

  • DataItem — The tag's bound data item (if the tag is not custom).
  • IsCustom -Returns whether the current tag is custom (not stored in the assigned data source).
  • RemoveTagAction — The predefined action that removes the tag.
  • DisplayText — The tag's text.

Item Display Template

Nancy Davolio
Nancy Davolio

Use the ItemDisplayTemplate property to customize the appearance of TagBox items. The property acceptsTagBoxItemDisplayTemplateContext object as its context parameter. You can use the parameter's members to obtain item information:

In this demo, the ItemDisplayTemplate property is used to display TagBox items in a card-like view. The TagDisplayTemplate property customizes the appearance of TagBox tags.

Column Cell Display Template

Singaporean Hokkien Fried Mee
Mozzarella di Giovanni
Tofu

The ColumnCellDisplayTemplate property allows you to specify custom content and change the appearance of cells associated with TagBox columns. The property accepts TagBoxColumnCellDisplayTemplateContext object as its context parameter. You can use parameter members to obtain column information:

This demo customizes the appearance of different columns.

Empty Data Area Template

The DevExpress Blazor TagBox displays an “empty data area” in the following instances:

  • The Data property is not set.
  • The specified data source does not contain items.
  • You use the DataAsync property or the CustomData property to bind the List Box to a data source. The component sends the first request to a remote data source and waits for an appropriate response.

Define the EmptyDataAreaTemplate to customize content displayed in this empty region. The template's context parameter includes the IsDataLoading property. This property allows you to determine whether TagBox is still loading data.

Validation

This demo illustrates how to add the TagBox to Blazor's standard EditForm component. This component allows data validation.

Use the TagBox's ValidateBy property to specify whether to validate the editor's tags or the drop-down list's selected items. In this demo, this property is set to TagBoxValidateBy.Tags. The Tags property's bound field is marked with the Required attribute and a custom data annotation attribute that validates email formats.

Users can select email recipients from a drop-down list or type email addresses in the edit box. After a user types an email address, the edit box is underlined in red or green: red indicates the editor contains an invalid tag(s) or is empty; green indicates the tags are valid. You can also use the ShowValidationIcon property to specify whether editors should display validation icons.