All files and folder shown as undefined

1 Answer 23 Views
FileManager
Rob
Top achievements
Rank 1
Veteran
Iron
Rob asked on 07 Dec 2021, 01:36 AM

I copied the demonstration code and controller ( from GitHub) and slightly modified to suit.

The view is very simple

<body>
    <div id="example">
        <div id="filemanager"></div>

        <script>
        $("#filemanager").kendoFileManager({
            dataSource: {
                schema: kendo.data.schemas.filemanager,
                transport: {
                    read: {
                        url: '@Url.Action("Read", "FileManager")',
                        method: "POST"
                    }
                }
            },
            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>
    </div>




</body>
</html>


The Data returned from the controller is this ( copy and paste from the browser)

[{"name":"English","size":0,"path":"English","extension":"","isDirectory":true,"hasDirectories":false,"created":"\/Date(1638409250788)\/","createdUtc":"\/Date(1638409250788)\/","modified":"\/Date(1638834574019)\/","modifiedUtc":"\/Date(1638834574019)\/"},{"name":"Swedish","size":0,"path":"Swedish","extension":"","isDirectory":true,"hasDirectories":false,"created":"\/Date(1638409251098)\/","createdUtc":"\/Date(1638409251098)\/","modified":"\/Date(1638501536659)\/","modifiedUtc":"\/Date(1638501536659)\/"}]

I have tried viewing a folder with lots of file.. the number of File is always right.. but something is going wrong with the reading of the data being returned The initial controller code I used set path as a path and filename. I changed it to above to match what I can see returning for the examples provided.
So  now I believe the JSON being returned from the online samples that are using the same backend are identical to what I am returning. 

I am using 2021.1.330.     The only thing I can think of is that there was a change in the Schema between versions? But I cannot find anything about this

I haven't got much hair left these days... would really appreciate a pointer to at least what I could be checking.

Many thanks

Rob

1 Answer, 1 is accepted

Sort by
0
Accepted
Rob
Top achievements
Rank 1
Veteran
Iron
answered on 07 Dec 2021, 03:36 AM

OK, I found it

There seems to have been a change to the case of the fields between versions

If I look at the demo's online and watch the read JSON response, everything is camelCase.

But then I dug into my version, I can see the field is capitalised ( see new file uploaded)

So I changed the code from the GitHub data source that is provided, to return the fields with a capital, and it works now

I used the controller from kendo-ui-demos-service

 public virtual JsonResult Read(string target)
        {
            var path = NormalizePath(target);

            if (AuthorizeRead(path))
            {
                try
                {
                    directoryProvider.Server = Server;

                    var result = directoryProvider
                        .GetContent(path, DefaultFilter)
                        .Select(f => new
                        {
                            name = f.Name,
                            size = f.Size,
                            path = ToVirtual(f.Path),
                            extension = f.Extension,
                            isDirectory = f.IsDirectory,
                            hasDirectories = f.HasDirectories,
                            created = f.Created,
                            createdUtc = f.CreatedUtc,
                            modified = f.Modified,
                            modifiedUtc = f.ModifiedUtc
                        });

                    return Json(result, JsonRequestBehavior.AllowGet);
                }
                catch (DirectoryNotFoundException)
                {
                    throw new HttpException(404, "File Not Found");
                }
            }

            throw new HttpException(403, "Forbidden");
        }
But had to adjust this to return capitalised fields 

I assume this is a version issue. I did check the history in GitHub earlier, but didn't see any changes. Maybe I missed it

Sorry to take your time and hopefully this helps someone else
Tags
FileManager
Asked by
Rob
Top achievements
Rank 1
Veteran
Iron
Answers by
Rob
Top achievements
Rank 1
Veteran
Iron
Share this question
or