fileDataItem

Gets the file data item associated with a jQuery file element within a message.

Parameters

message Object

The message object containing the file.

file jQuery

The jQuery file element.

Returns

Object - The file data object.

Example

<div id="chat"></div>
<script>
let messagesData = [
    {
        id: 1,
        text: "This message has files attached. Check the console to see file data.",
        authorId: "user1",
        authorName: "John Doe",
        authorImageUrl: "https://demos.telerik.com/kendo-ui/content/web/Customers/RICSU.jpg",
        files: [
            { name: "document.pdf", size: 245760, extension: "pdf" },
            { name: "image.jpg", size: 156000, extension: "jpg" }
        ],
        timestamp: new Date(2026, 0, 1, 9, 0)
    },
    {
        id: 2,
        text: "The fileDataItem method helps you get file information.",
        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: "user2",
    dataSource: messagesData
}).data("kendoChat");

// Example: Get file data item from the first message
setTimeout(function() {
    let messageElement = chat.wrapper.find(".k-message").first();
    if (messageElement.length > 0) {
        let messageData = chat.dataItem(messageElement);
        let fileElement = messageElement.find(".k-chat-file").first();
        if (fileElement.length > 0) {
            let fileData = chat.fileDataItem(messageData, fileElement);
            console.log("File name:", fileData.name);
            console.log("File size:", fileData.size);
        }
    }
}, 1000);
</script>
In this article
fileDataItem
Not finding the help you need?
Contact Support