FileManager: How to force a full TreeView refresh?
1 Answer 18 Views
Patrick
Top achievements
Rank 1
Iron
Patrick asked on 15 Jun 2021, 09:36 AM

I overwrote the FileManagers MoveCommand to implement my own logic. Afterwards I do call the FileManagers refresh method. Unfortunately, this seems to update only the ListView/GridView, but not the TreeView.

So, when I move a subfolder between two folders, the folder has been moved correctly, the GridView/ListView then refreshes perfectly, but in the TreeView I can still see the subfolder in the old location  (source folder). If I click the TreeViews target folder, the moved subfolder occurs. When I click the TreeViews source folder, the subfolder is still there (although it should not).

How can I force the FileManagers TreeView to do a full refresh (and reload all data)?

Thanks for any advice!

Patrick

1 Answer, 1 is accepted

Sort by
1
Accepted
Patrick
Telerik team
answered on 17 Jun 2021, 06:23 PM | edited on 17 Jun 2021, 06:27 PM

Hello Patrick,

One way in which you can refresh the dataSource after moving a subfolder to another subfolder is to call the dataSource's read method.  In this case, you could do it after the remove action during the command event:

 

        $("#filemanager").kendoFileManager({
            dataSource: {
                schema: kendo.data.schemas.filemanager,
                transport: {
                    read: {
                        url: "/FileManagerData/Read",
                        method: "POST"
                    },
                    create: {
                        url: "/FileManagerData/Create",
                        method: "POST"
                    },
                    update: {
                        url: "/FileManagerData/Update",
                        method: "POST"
                    },
                    destroy: {
                        url: "/FileManagerData/Destroy",
                        method: "POST"
                    }
                }
            },
            uploadUrl: "/FileManagerData/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" }
                ]
            },
            command: function (e) {

                //after removing, read the datasource to refresh data
                if (e.action == "remove") {
                    e.sender.dataSource.read();
                }               
            },
            draggable: true,
            resizable: true
        });

 

Hopefully this helps with your current custom implementation of the MoveCommand.  Otherwise, please take a look at that and ensure the folder has been successfully created/deleted.   

Regards,
Patrick
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Patrick
Top achievements
Rank 1
Iron
commented on 21 Jun 2021, 05:45 PM

Hello Patrick,

Calling the dataSource's read method, was the right thing to do. Thank you very much!

Best regards,
Patrick
Patrick
Telerik team
commented on 21 Jun 2021, 07:37 PM

No problem at all! Glad it's working well!  
Asked by
Patrick
Top achievements
Rank 1
Iron
Answers by
Patrick
Telerik team
Share this question
or