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

[Solved] Date columns (ajax binding) formatting problems

1 Answer 99 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.
Joan Vilariño
Top achievements
Rank 2
Joan Vilariño asked on 25 Mar 2010, 11:20 AM
Hi again.

I'm trying to create a grid with two date columns. The grid is Ajax bound and it's ignoring the .Format(...) method... here's the example:

<%= Html.Telerik().Grid<LocalViewModel.LocalCentroServicioVM>() 
    .Name("GridCentrosServicio"
    .DataKeys(keys=>keys.Add(o=>o.Id)) 
    .DataBinding(binding=>binding.Ajax().Select("_obtenerCentrosServicio","Local")) 
    .Sortable() 
    .Pageable() 
    .Filterable() 
    .Columns(col => 
                 { 
                     col.Bound(o => o.CentroServicio.TipoServicio.Nombre).Title("Tipo").Width(200); 
                     col.Bound(o => o.CentroServicio.Nombre); 
                     col.Bound(o => o.FechaAlta).Format("{0:dd/MM/yyyy}").Width("200px"); 
                     col.Bound(o => o.FechaBaja).Format("{0:dd/MM/yyyy}").Width("200px"); 
                 })%> 
 

the object model properties for this dates is this one:

            [DataType(DataType.Date), DisplayName("Fecha Alta")] 
            public DateTime FechaAlta { getset; } 
            [DataType(DataType.Date), DisplayName("Fecha Baja")] 
            public DateTime FechaBaja { getset; } 

The resuls is the grid showing the long date format "Tue Mar 16 15:29:05 UTC+0100 2010" instead the one I provide.

Any clue on this?

Thanks 

1 Answer, 1 is accepted

Sort by
0
Joan Vilariño
Top achievements
Rank 2
answered on 25 Mar 2010, 11:28 AM
Fixed... the problem comes when the grid is inside a TabStrip, and it's related to this post I posted yesterday:


The fix is registering the needed .js file (I had to do some testing to find out which ones) in the main view like this:

     <% Html.Telerik().ScriptRegistrar().DefaultGroup(group => group 
                                                              .Add("telerik.common.js"
                                                              .Add("telerik.grid.js"
                                                              .Add("telerik.grid.filtering.js"
                                                              .Add("telerik.calendar.js"
                                                              .Add("telerik.grid.grouping.js"
                                                              .Add("telerik.datepicker.js")); %>       

Thanks anyway!
Tags
Grid
Asked by
Joan Vilariño
Top achievements
Rank 2
Answers by
Joan Vilariño
Top achievements
Rank 2
Share this question
or