JavaScript/jQuery Chat API

The Chat UI component is an interactive interface that allows users to send and receive messages in real time.

import Chat from "devextreme/ui/chat"

Options

A configuration object for the Chat UI component.

Name Description
activeStateEnabled

Specifies whether the UI component changes its visual state as a result of user interaction.

alerts

A list of available alerts.

dataSource

Binds the UI component to data.

dayHeaderFormat

Specifies the day header format.

disabled

Specifies whether the UI component responds to user interaction.

elementAttr

Specifies the global attributes to be attached to the UI component's container element.

focusStateEnabled

Specifies whether the Chat's input element can be focused using keyboard navigation.

height

Specifies the UI component's height.

hoverStateEnabled

Specifies whether the UI component changes its state when a user pauses on it.

items

Specifies an array of chat messages.

messageComponent

An alias for the messageTemplate property specified in React. Accepts a custom component. Refer to Using a Custom Component for more information.

messageRender

An alias for the messageTemplate property specified in React. Accepts a rendering function. Refer to Using a Rendering Function for more information.

messageTemplate

Specifies a custom template for a chat message.

messageTimestampFormat

Specifies the message timestamp format.

onDisposing

A function that is executed before the UI component is disposed of.

onInitialized

A function used in JavaScript frameworks to save the UI component instance.

onMessageEntered

A function that is executed after a message is entered into the chat.

onOptionChanged

A function that is executed after a UI component property is changed.

onTypingEnd

A function that is called 2 seconds after a user stops typing or after a message is entered.

onTypingStart

A function that is called after a user starts typing.

reloadOnChange

Specifies whether the Chat UI component displays newly entered messages immediately. This property only applies if dataSource is used.

rtlEnabled

Switches the UI component to a right-to-left representation.

showAvatar

Specifies whether to show avatars.

showDayHeaders

Specifies whether to show day headers.

showMessageTimestamp

Specifies whether to show message time stamps.

showUserName

Specifies whether to show user names.

typingUsers

An array of users who are currently typing.

user

Specifies the current chat user (messages displayed on the right side).

visible

Specifies whether the UI component is visible.

width

Specifies the UI component's width.

Methods

Name Description
beginUpdate()

Postpones rendering that can negatively affect performance until the endUpdate() method is called.

defaultOptions(rule)

Specifies the device-dependent default configuration properties for this component.

dispose()

Disposes of all the resources allocated to the Chat instance.

element()

Gets the root UI component element.

endUpdate()

Refreshes the UI component after a call of the beginUpdate() method.

focus()

Sets focus to the Chat's input element.

getDataSource()

Gets the DataSource instance.

getInstance(element)

Gets the instance of a UI component found using its DOM node.

instance()

Gets the UI component's instance. Use it to access other methods of the UI component.

off(eventName)

Detaches all event handlers from a single event.

off(eventName, eventHandler)

Detaches a particular event handler from a single event.

on(eventName, eventHandler)

Subscribes to an event.

on(events)

Subscribes to events.

option()

Gets all UI component properties.

option(optionName)

Gets the value of a single property.

option(optionName, optionValue)

Updates the value of a single property.

option(options)

Updates the values of several properties.

registerKeyHandler(key, handler)

Registers a handler to be executed when a user presses a specific key.

renderMessage(message)

Renders a new message.

repaint()

Renders the component again without reloading data. Use the method to update the component's markup and appearance dynamically.

resetOption(optionName)

Resets a property to its default value.

Events

Name Description
disposing

Raised before the UI component is disposed of.

initialized

Raised only once, after the UI component is initialized.

messageEntered

Raised after a message is entered.

optionChanged

Raised after a UI component property is changed.

typingEnd

Raised 2 seconds after a user stopped typing or after a message is entered.

typingStart

Raised when a user starts typing.

See Also

Types

Name Description
Alert

A configuration object for an alert.

DisposingEvent

The type of the disposing event handler's argument.

InitializedEvent

The type of the initialized event handler's argument.

Message

A configuration object for a message.

MessageEnteredEvent

The type of the messageEntered event handler's argument.

OptionChangedEvent

The type of the optionChanged event handler's argument.

TypingEndEvent

The type of the typingEnd event handler's argument.

TypingStartEvent

The type of the typingStart event handler's argument.

User

A configuration object for a user.