This is a migrated thread and some comments may be shown as answers.
Display TimeSpan field in grid as mm:ss
2 Answers 7 Views
This is a migrated thread and some comments may be shown as answers.
Roger
Top achievements
Rank 2
Roger asked on 16 Mar 2021, 05:41 PM

I have a TimeSpan field called duration that is being returned from MS-Sql Server.  I am trying to format that field for display in a grid as mm:ss

I've parsing it as a date for a template but that hasn't worked as I don't believe it is a date.

 

{
                    field: "duration",
                    title: "Duration",
                    template: "#= kendo.toString(kendo.parseDate(duration), 'mm:ss') #",
                    width: 120,
                    filterable: false
                },

Any suggestions greatly appreciated.

2 Answers, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 19 Mar 2021, 04:07 PM

Hi Roger,

Thank you for the code snippet and the detailed description of your query.

Since the TimeSpan structure is not available in JavaScript, you could review the recommendations in the forum thread below. They are applicable for jQuery as well.

https://www.telerik.com/forums/grid-timespan-object-object-asp-net-mvc#Y1bPfd-6nkKeaDUHG8MCLQ

{ field: "MyTimeSpan", title: "Time Span field", template:"#= kendo.format('{0:00}:{1:00}', MyTimeSpan.Hours, MyTimeSpan.Minutes) #" }

Also, attached is a runnable sample project, based on the example above.

Let me know if you need any further assistance or if you have any additional queries.

 

Regards, Mihaela Lukanova 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.

0
Roger
Top achievements
Rank 2
answered on 24 Mar 2021, 06:40 PM
Thank you Miheala - I found the attached program a little hard to open - so transformed it to the following Kendo Dojo - which seems to work: https://dojo.telerik.com/@rswetnam/IwAgOdUH/15.  Thanks for your help.
Tags
Grid
Asked by
Roger
Top achievements
Rank 2
Answers by
Mihaela
Telerik team
Roger
Top achievements
Rank 2
Share this question
or