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

Parsing UTC dates from filemanager datasource

1 Answer 99 Views
FileManager
This is a migrated thread and some comments may be shown as answers.
Dion
Top achievements
Rank 1
Veteran
Dion asked on 27 Aug 2020, 12:20 AM

Hi, 

I am trying to use the .net core FileManager component.I have implemented a custom back end that no longer reads the file system, instead integrates with my database and Azure blob storage. Everything working ok for that. 

 

The issue I'm having is with the display for the created and modified timestamps.

My users will be in different timezones so I will need to convert the timestamps to the user's local time. I'm storing timestamps in utc in the database

As far as I can tell the current file manager widget is not setup for that.

I'm trying to intercept the datasource so that I can parse the data objects, read the Utc timestamps, convert them to the user's local timezone in the client side, and populate the non-utc timestamps, so they show correctly in the filemanager control.

I can't yet work out how to do that though. can anyone help?

 

many thanks

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 31 Aug 2020, 02:31 PM

Hi Dion,

To change the timezone client-side the schema.parse configuration of the FileManager's dataSource can be used as demonstrated in this Dojo example

The parse function in the linked example is defined as follows:

        var fileManagerSchema = kendo.data.schemas.filemanager;
        fileManagerSchema.parse = function(data){
          var date = data[0].created.substring(data[0].created.lastIndexOf("(") + 1,   data[0].created.lastIndexOf(")"));
          data[0].created = new Date(Number(date)).toLocaleString("en-US", {timeZone: "Australia/Brisbane"});
          return data;
        }

Then the fileManagerSchema's value is passed to the schema of the FileManager's component. Using the approach with the parse function, we can edit the data coming from the server in a way it fits the needs of our business requirements. In the above example, only the zero element of the dataSource's data is edited. 

I hope the linked example will help you implement the targeted functionality in the application you are working on.

Regards,
Petar
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/.

Tags
FileManager
Asked by
Dion
Top achievements
Rank 1
Veteran
Answers by
Petar
Telerik team
Share this question
or