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

[Solved] ASP.NET MVC Kendo Grid ClientTemplate issue - date formatting

1 Answer 583 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 08 Oct 2014, 01:27 PM
I have a kendo grid that is loaded in a Kendo window. There is a date field in the grid that displays the date as /Date(.......)/
Also looked at the following thread http://www.telerik.com/forums/grid-client-template-and-date-formats, but the solutions provided there didn't work.

e.g. If I used this format:
columns.Bound(s => s.DateOpened).Template(@<Text></Text>).ClientTemplate("#=kendo.toString(DateOpened,'MM/dd/yyyy')#");

I end up getting a Invalid template error.

Changing it to:
columns.Bound(s => s.DateOpened).Template(@<Text></Text>).ClientTemplate("\\#=kendo.toString(DateOpened,'MM/dd/yyyy'\\)#");

displayed the date as /Date(1406727900000)/

Here is my grid sample:

<script type="text/x-kendo-template" id="SeverityDetailsTemplate">
    @(Html.Kendo().Grid<TestViewModel>()
    .Name("TestGrid")
    .Columns(columns =>
    {
        columns.Bound(s => s.CategoryId).Visible(false);
        columns.Bound(s => s.Name)
        columns.Bound(s => s.District)
        columns.Bound(s => s.CategoryName)
        columns.Bound(s => s.DateOpened).Template(@<Text></Text>).ClientTemplate("\\#=kendo.toString(DateOpened,'MM/dd/yyyy')\\#");
        columns.Bound(s => s.DateClosed);
        columns.Bound(s => s.Description);
    })
            .DataSource(ds => ds
                .Ajax()
                .PageSize(15)
                .Read(read => read.Action("GetTestGridDetails", "Home", new { categoryId = "#=CategoryId#" }))
                .Events(events => events.Error("grid_errorHandler"))
            )
            .Scrollable(s => s.Enabled(false))
            .Pageable(page => page.Refresh(false).PageSizes(new[] { 5, 10, 15, 20 }))
            .Resizable(r => r.Columns(true))
            .Sortable()
            .ToClientTemplate()
         )
</script>

The DateOpened field is of DateTime data type.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 10 Oct 2014, 07:51 AM
Hello Keith,

The configuration that you shared looks all fine and we are not where the issue is coming from. We will need a small sample project or a live URL to investigate what causes this.

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Keith
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or