dataItem
Gets the data item (Message object) associated with a jQuery message element.
Parameters
message jQuery
The jQuery message element.
Returns
Object
- The message data object.
Example
<div id="chat"></div>
<script>
let messagesData = [
{
id: 1,
text: "This is the first message. Click this message to see its data in the console.",
authorId: "user1",
authorName: "John Doe",
authorImageUrl: "https://demos.telerik.com/kendo-ui/content/web/Customers/RICSU.jpg",
timestamp: new Date(2026, 0, 1, 9, 0)
},
{
id: 2,
text: "This is the second message with different data.",
authorId: "user2",
authorName: "Jane Smith",
authorImageUrl: "https://demos.telerik.com/kendo-ui/content/web/Customers/LONEP.jpg",
timestamp: new Date(2026, 0, 1, 9, 5)
}
];
let chat = $("#chat").kendoChat({
authorId: "user1",
dataSource: messagesData
}).data("kendoChat");
// Example: Get data item of the first message
setTimeout(function() {
let messageElement = chat.wrapper.find(".k-message").first();
if (messageElement.length > 0) {
let messageData = chat.dataItem(messageElement);
console.log("Message text:", messageData.text);
console.log("Author:", messageData.authorName);
}
}, 1000);
</script>
In this article