Upload Template: How to format file size (#=size#) in KB instead of Bytes and with two decimals?

2 Answers 37 Views
FileManager Upload
Patrick
Top achievements
Rank 1
Iron
Patrick asked on 24 May 2021, 08:40 PM

I added a custom template for the Upload Widget. The file size (#=size#) prints to a byte value. How can I format the file size (#=size#) to print in KB instead of Bytes - and with two decimals? (like the upload widgets default)

I added the template as a function, as mentioned here.

Thanks for any advice!

Patrick

Patrick
Top achievements
Rank 1
Iron
commented on 03 Jun 2021, 05:15 PM | edited

-

2 Answers, 1 is accepted

Sort by
0
Accepted
Patrick
Top achievements
Rank 1
Iron
answered on 03 Jun 2021, 05:17 PM
Solution: 
#=kendo.toString(size/1024,"n2")# KB

1
Martin
Telerik team
answered on 27 May 2021, 11:26 AM

Hello, Patrick,

You can divide the bytes to 1000 and you will get the amount in kilobytes. Here is a small example for reference.

Let me know if you have any further questions.

Regards,
Martin
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 Upload
Asked by
Patrick
Top achievements
Rank 1
Iron
Answers by
Patrick
Top achievements
Rank 1
Iron
Martin
Telerik team
Share this question
or