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

[Solved] Grid DateTime format changes on ClientTemplate with Ajax on Client Columns

3 Answers 269 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin
Top achievements
Rank 1
Kevin asked on 15 Apr 2011, 04:30 PM

My Html.Telerik().Grid when set to databinding.Ajax the following happens:

        .Columns(columns =>
        {
            columns.Bound(o => o.Created)
                .Title(" ");
})

Results in:  4/15/2011 8:55:53 AM

However, 
        .Columns(columns =>
        {
            columns.Bound(o => o.Created)
                .ClientTemplate("<#= Created #>")
                .Title(" ");
})

Results in:  
Fri Apr 15 2011 08:55:53 GMT-0400 (Eastern Daylight Time)

How do I format <#= Created #> to equal 4/15/2011 8:55:53 AM

3 Answers, 1 is accepted

Sort by
0
Ciget
Top achievements
Rank 1
answered on 01 Jun 2011, 11:18 AM
I have the same problem with formatting. So how we can format datetime value in clienttemplate method ????
0
Carson
Top achievements
Rank 1
answered on 29 Aug 2011, 07:57 PM
Good question. Please let us know.
0
Atanas Korchev
Telerik team
answered on 30 Aug 2011, 06:37 AM
Hello,

 You can format a date in the client template like this:

column.Bound(p => p.CreatedDate)
    .ClientTemplate("<#= $.telerik.formatString("{0:dd/MM/yyyy}", CreatedDate) #>");

Regards,

Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Ciget
Top achievements
Rank 1
Carson
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or