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

Grid + detail + date format GMT

2 Answers 270 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Farid
Top achievements
Rank 1
Farid asked on 13 Jun 2013, 04:55 PM
Hello,

I have a grid that display a date. The controller send to the grid the dates in the right format 'dd/mm/yyyy hh:mm:ss'  but the grid displays dates such as  'Sun, 09 Mar 2008 16:05:07 GMT 0200 (Romance Daylight Time)'.  Is it possible to set the default format in french without reformating the data?
PS: i set the culture in french.


@(Html.Kendo().Grid<Scan>(Model)
                .Name("grid_Time_" + ViewData["ID"])
                .Columns(columns =>
                             {
                                  
                                 columns.Bound(e =>  e.Timestamp).Title("Date").Width(150).Format("{0:dd/MM/yyyy hh:mm:ss}");
                                 columns.Bound(e => e.GatewayID).Width(20);
                             })
                .Sortable()
                .Pageable()
                .ClientDetailTemplateId("template2")
                .DataSource(dataSource => dataSource
                          .Ajax()
                          .PageSize(30)
                          .Model(model =>
                                      {
                                          model.Id(d => d.GatewayID);
 
                                      })
 
                )
                .Events(events => events.DataBound("dataBound"))
                )

I have a client template which is loading with two values :
.Read(read => read.Action("ReadScannedMeterByGateway", "Flottes", new { Id = "#=GatewayID#",Timestamp="#=Timestamp#" }))
How can i send the dates with the format 'dd/mm/yyyy hh:mm:ss'  to server?

2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 17 Jun 2013, 08:55 AM
Hi Farid,

Please find the answers of your questions below:

  • Is it possible to set the default format in french without reformating the data?  - Basically you should apply format if you need the date formatted differently. In current case you can use one of the default named masks to format the date based on the current culture. Please check the example below:   
    //if the culture is set to FR the date will be formatted:
    //G: "dd/MM/yyyy HH:mm:ss"
    columns.Bound(p => p.OrderDate).Format("{0:G}");
  • You can format the date using KendoUI format method in the template:  
    .Read(read => read.Action("ReadScannedMeterByGateway", "Flottes", new { Id = "#=GatewayID#",Timestamp="#=kendo.format('{0:G}', Timestamp)#" }))

Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Farid
Top achievements
Rank 1
answered on 17 Jun 2013, 09:22 AM
Hi Vladimir,

Your solution works great ! Thank you !
Tags
Grid
Asked by
Farid
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Farid
Top achievements
Rank 1
Share this question
or