MultiColumnComboBox Events
This article describes the events of the Telerik MultiColumnComboBox for Blazor.
ValueChanged
The ValueChanged event fires upon every change of the user selection. When custom values are enabled, it fires upon every keystroke, like in a regular <input> element.
The type of the argument in the lambda expression must match the Value type of the component, and the ValueField type (if ValueField is set).
Handle ValueChanged
Handle ValueChanged with custom values - the event fires on every keystroke
The event is an
EventCallback. It can be synchronous and returnvoid, or asynchronous and returnasync Task. Do not useasync void.
The lambda expression in the handler is required by the framework: https://github.com/aspnet/AspNetCore/issues/12226.
OnChange
The OnChange event represents a user action - confirmation of the current value/item. It is suitable for handling custom values the user can enter as if the MultiColumnComboBox was an input. The key differences with ValueChanged are:
OnChangedoes not prevent two-way binding (the@bind-Valuesyntax)OnChangefires when the user pressesEnterin the input, or blurs the input (for example, clicks outside of the combo box). It does not fire on every keystroke, even whenAllowCustom="true", but it fires when an item is selected from the dropdown. To get the selected item, you can check if the new value is present in the data source.
Handle OnChange without custom values - to get a value from the list, you must write text that will match the text of an item (e.g, "item 5").
Handle OnChange with custom values - the event fires on blur or enter
OnRead
Get familiar with the common
OnReadevent documentation first.
You can use the OnRead event to provide data to the component according to some custom logic, the user input, or the current virtual scroll position. The event fires when:
- The component initializes.
- The user filters.
- The user scrolls with virtualization enabled.
You can also call remote data through async operations.
Find out how to get the applied by filtering and grouping criteria.
When using OnRead, make sure to set TItem and TValue.
You can also debounce the service calls and implement minimum filter length.
Custom Data according to the user input in the ComboBox
The
OnReadhandler should change only the data of the component, and not other parameters such asValue. This can lead to issues with the asynchronous nature of the event, and race conditions can occur with the arrival of the new data. Moreover, such a change is likely to be unexpected by the user and cause bad UX.
Custom sort of grouped data with OnRead
OnOpen
The OnOpen event fires before the MultiColumnComboBox popup renders.
The event handler receives as an argument an MultiColumnComboBoxOpenEventArgs object that contains:
| Property | Description |
|---|---|
IsCancelled | Set the IsCancelled property to true to cancel the opening of the popup. |
OnClose
The OnClose event fires before the MultiColumnComboBox popup closes.
The event handler receives as an argument an MultiColumnComboBoxCloseEventArgs object that contains:
| Property | Description |
|---|---|
IsCancelled | Set the IsCancelled property to true to cancel the closing of the popup. |
OnBlur
The OnBlur event fires when the component loses focus.
Handle the OnBlur event