removeMessage
Removes a message from the chat by marking it as deleted.
Parameters
message Object
The message object to remove.
Returns
Boolean
- Success status of the removal operation.
Example
<div id="chat"></div>
<script>
let messagesData = [
{
id: 1,
text: "This message will be removed automatically after 3 seconds.",
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 message will remain visible.",
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");
// Remove the first message after 3 seconds
setTimeout(function() {
let messageObject = chat.dataSource.get(1); // Get message with id 1
if (messageObject) {
let success = chat.removeMessage(messageObject);
console.log("Message removal success:", success);
}
}, 3000);
</script>
In this article