This is a migrated thread and some comments may be shown as answers.

Dragging Files to a Folder - Targeted Folder is not refreshed

1 Answer 32 Views
FileManager
This is a migrated thread and some comments may be shown as answers.
Guilherme
Top achievements
Rank 1
Guilherme asked on 22 Apr 2021, 11:50 AM

Hello

How can I make a $("#FileManager").data("kendoFileManager").refresh() everytime I open a folder on Kendo UI File Manager?

This is my problem:

When I browse to an empty folder, the folder gets reloaded every time I go into the folder.

When I browse to a folder that has files, the folder gets reloaded the first time and afterwards it won't reload/refresh anymore.

Practical case:

- Root
     - FolderA
          - File1
          - File2
     - FolderB

- If I go to FolderA, it will load both files
- When I drag File1 into FolderB, if I go to FolderB I will see the File1 inside
- I go back to FolderA and I drag File2 into FolderB
- If I go to FolderB I can only see File1 inside, FolderB was not reloaded when I went there again

The only 2 ways I found so far to see File2 inside of FolderB are:
- refreshing the whole page
- moving File1 again to another folder, when I do that File2 becomes visible again (a refresh is made);

The second way only happeens because I do a $("#FileManager").data("kendoFileManager").refresh(); but this only refreshes the folder I am currently at.

I would like to make a $("#FileManager").data("kendoFileManager").refresh() everytime I open a folder on Kendo UI File Manager.

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 27 Apr 2021, 10:12 AM

Hi,

You can handle the Navigate event and force the entry to be reloaded. Here you are a code sample: 

@(Html.Kendo().FileManager().Name("filemanager")
    .DataSource(ds =>
        {
            ds.Read(operation => operation
            .Type(HttpVerbs.Post)
            .Action("Read", "FileManagerData")
        );
        ds.Destroy(operation => operation
            .Type(HttpVerbs.Post)
            .Action("Destroy", "FileManagerData")
        );
        ds.Create(operation => operation
            .Type(HttpVerbs.Post)
            .Action("Create", "FileManagerData")
        );
        ds.Update(operation => operation
            .Type(HttpVerbs.Post)
            .Action("Update", "FileManagerData")
        );
    })
    .UploadUrl("Upload", "FileManagerData")
    .Events(events => events.Navigate("onNavigate"))
)

@section scripts {
<script>
    function onNavigate(ev) {
        var filemanager = ev.sender;
        var path = ev.path;
        var entry = filemanager.dataSource.get(path);
        if (entry.loaded()) {
            entry.loaded(false);
        }
    }
</script>
}

Regards,
Ianko
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.

Guilherme
Top achievements
Rank 1
commented on 29 Apr 2021, 07:54 AM | edited

Hi. That code isn't working on my end. When I use the left folder panel of the File Manager, if the folder has at least 1 file inside, the first click on the folder it will load. If I click on another folder and click again the previous folder, it is not reloading. It is using what's cached.

Setting the flag _loaded as false is not forcing the file manager to reload that specific folder when opening it. I got exactly that same code on my end and the flag is being set as false, just doesn't do anything.
Aleksandar
Telerik team
commented on 04 May 2021, 07:25 AM

Hi Guilherme,

I created a sample application to test the above and can confirm I was able to observe the issue you have experienced. Indeed calling the entry.loaded(false) does not reset the loaded flag and does not force the FileManager to reload the data. I have therefore logged a Bug on your behalf and you can monitor the status of the issue via this GitHub item:

https://github.com/telerik/kendo-ui-core/issues/6401

That said, I tested several possible approaches as workarounds, but could not successfully achieve the desired behavior. I can therefore suggest monitoring the item, linked above, for further details on the issue.

Finally, as a token of gratitude for helping us identify this issue I have updated your Telerik points.

Tags
FileManager
Asked by
Guilherme
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or