Mapping webapi response object to Filemanager's schema

1 Answer 20 Views
Data Source FileManager
Techlancer
Top achievements
Rank 1
Techlancer asked on 11 Dec 2021, 03:28 PM

Hi

I am using FileManager Jquery component that get the list of the files from an external rest api (json format) but the response object does not follow the default kendo.data.schemas.filemanager.

for example, rest api give file name field as "fileName" instead of "name".

Please let me know if there is a standard way to do this mapping.

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 15 Dec 2021, 11:16 AM

Hello,

You can define your own Schema model so that you can set up the field for the name. Like in this example: 

    $("#filemanager").kendoFileManager({               
        dataSource: {
          schema: {
          	model: {
                id: "path",
                hasChildren: "hasDirectories",
                fields: {
                    name: {editable: true, type: "String", defaultValue: "New Folder", from: "fileName" },
                    size: {editable: false, type: "Number"},
                    path: {editable: false, type: "String"},
                    extension: {editable: false, type: "String"},
                    isDirectory: {editable: false, defaultValue: true, type: "Boolean"},
                    hasDirectories: {editable: false, defaultValue: false, type: "Boolean"},
                    created: { from: "created", type: "Date", editable: false},
                    createdUtc: { from: "createdUtc", type: "Date", editable: false },
                    modified: { from: "modified", type: "Date", editable: false},
                    modifiedUtc: { from: "modifiedUtc", type: "Date", editable: false }
                }
            }
          }
          ...
        }
      ...
    }); 

 

Another way is to use the schema.parse option to preprocess the data fetched. 

Regards,
Ianko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

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