How items: [...] work . And How can the folder read the items corresponding to each folder when the URL has only the data of the Folder.

1 Answer 212 Views
FileManager
Stark
Top achievements
Rank 1
Iron
Iron
Stark asked on 06 May 2021, 01:16 PM

This is demo code about filemanage: https://demos.telerik.com/kendo-ui/filemanager/index


<script>
        $("#filemanager").kendoFileManager({
            dataSource: {
                schema: kendo.data.schemas.filemanager,
                transport: {
                    read: {
                        url: "/kendo-ui/service/FileManager/Read",
                        method: "POST"
                    },
                    create: {
                        url: "/kendo-ui/service/FileManager/Create",
                        method: "POST"
                    },
                    update: {
                        url: "/kendo-ui/service/FileManager/Update",
                        method: "POST"
                    },
                    destroy: {
                        url: "/kendo-ui/service/FileManager/Destroy",
                        method: "POST"
                    }
                }
            },
            uploadUrl: "/kendo-ui/service/FileManager/Upload",
            toolbar: {
                items: [
                    { name: "createFolder" },
                    { name: "upload" },
                    { name: "sortDirection" },
                    { name: "sortField" },
                    { name: "changeView" },
                    { name: "spacer" },
                    { name: "details" },
                    { name: "search" }
                ]
            },
            contextMenu: {
                items: [
                    { name: "rename" },
                    { name: "delete" }
                ]
            },
            draggable: true,
            resizable: true
        });

        $(document).ready(function () {
            var filemanager = $("#filemanager").getKendoFileManager();

            filemanager.executeCommand({ command: "TogglePaneCommand", options: { type: "preview" } });
            filemanager.toolbar.fileManagerDetailsToggle.switchInstance.toggle();
        })
    </script>

I still don't understand, right at the items position there is nothing related to "tranport: read" but still can read the data of the items. So where is that data retrieved through?

This is link read data but it only of Folder: https://demos.telerik.com/kendo-ui/service/FileManager/Read

Can Admins explain in depth for me??

I am working on a project using filemanager and I am currently spending a lot of time. Hope Admins can help me.

THis is my Project code:


$("#filemanager").kendoFileManager({
            
        dataSource: {
            transport: {
                read: function (options) {
                    var that = this;
                    $.ajax({
                        url: "/_layouts/15/xxx/API/ApiHandler.ashx?tbl=like&func=getalllibrary",
                        
                        cache: false,
                        scriptCharset: "utf8",
                        dataType: "json",
                        method: "POST",
                        data: that.parameterMap ? that.parameterMap(options.data, "read") : options.data,
                        success: function (result) {
                            options.success(result);
                        }
                    });
                },
                
                destroy: function (options) {
                    
                    console.log("Here Hello"); //[error] not show log when click delete => cannot call function destroy
                }
            },
            schema: {
                data: 'data',
            }
        },
        toolbar: {
            items: [
                { name: "custom", type: "button", text: "Create", command: "MyCustomCommandCreate" },
                { name: "custom", type: "button", text: "Upload", command: "MyCustomCommandUpload" },
                { name: "sortDirection" },
                { name: "sortField" },
                { name: "changeView" },
                { name: "spacer" },
                { name: "details" },
                { name: "search" }
            ]
        },
        contextMenu: {
            items: [
                { name: "rename" },
                { name: "delete" },
                { name: "custom", text: "Detect", command: "MyCustomCommandDetect", spriteCssClass: "k-icon k-i-info" }
            ]
        },
        draggable: true,
        resizable: true
    });

    var filemanager = $("#filemanager").getKendoFileManager();

    filemanager.executeCommand({ command: "TogglePaneCommand", options: { type: "preview" } });
    filemanager.toolbar.fileManagerDetailsToggle.switchInstance.toggle();

    var filemanagerNS = kendo.ui.filemanager;

    filemanagerNS.commands.MyCustomCommandUpload = filemanagerNS.FileManagerCommand.extend({
        exec: function () {
            myWindow.data("kendoWindow").open();
            
        }
    });

    filemanagerNS.commands.MyCustomCommandCreate = filemanagerNS.FileManagerCommand.extend({
        exec: function () {
            myWindowAddLibrary.data("kendoWindow").open();
            
        }
    });

Click Folder not red hover and Console show Error: ( image1.png )

My json data in Url transport: read: ( image2.png )

Hope the admin can show me how to show the item corresponding to my folder

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 11 May 2021, 09:35 AM

Hi Stark,

From the provided information I am not sure I understand the issue correctly. Could you please elaborate a little bit more on the desired result?

As far as I understand you are not able to correctly load the files in the FileManager. I would suggest you take a look at the transport.read endpoint of the respective demo. You could find the Demo Service by clicking on the 'View Source' and then on the 'Sample service' tab. For convenience, below you will find links to:

- FileManagerController

- the Read action in the FileManagerController

Also, the following link to our documentation describes the FileManager remote data-binding:

- https://docs.telerik.com/kendo-ui/controls/data-management/filemanager/binding/remote

The items option could be used when configuring the items in the FileManager toolbar or in the Context Menu. On the link here you will find an example of adding a custom command to the FileManager Toolbar.

I hope this helps.

Regards,
Neli
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Stark
Top achievements
Rank 1
Iron
Iron
commented on 11 May 2021, 12:36 PM

Hi Admin,

Currently I have read all data from the folder to the corresponding folder image. But "children" data ( items: [...] ), can not call the function like the data side of the Folder.
This new link with new question:

https://www.telerik.com/forums/kendo-filemanager-data-children-cannot-call-function

Looking forward to hearing from Admin soon, thanks
Neli
Telerik team
commented on 14 May 2021, 09:05 AM

Hi Stark, 

I have just replied in the thread regarding the 'Kendo FileManager data children: " " cannot call function'. I would suggest you continue the related conversation there. 

Tags
FileManager
Asked by
Stark
Top achievements
Rank 1
Iron
Iron
Answers by
Neli
Telerik team
Share this question
or