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

Date Time Picker does not work in grid - MVC2 - 2011.1.315

4 Answers 145 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andre Jones
Top achievements
Rank 1
Andre Jones asked on 26 Mar 2011, 02:53 PM
Hi,

RE: Date Time Picker in Grid using MVC2 - 2011.1.315

I have been trying to get the datetime and time picker to work in the grid but it does not work.
As standard controls on a page, it works correctly, however as soon as I change it to use the grid control it ignores the values.

I have had to change the date and time formats, as my current culture is English UK, and it does not seem set the required format correctly...

My Region settings are English (United Kingdom)

Short Date: dd/MM/yyyy
Short Time: HH:mm

Possibly I am missing something "special" with grids? any assistance would be appreciated.

Attached I have included a project that has 2 pages (home - has a simple model and works correctly, grid - does not work for datetime, time (date however seems to work?))

Thanks in advance,

AJ

4 Answers, 1 is accepted

Sort by
0
Terry Burns-Dyson
Top achievements
Rank 1
answered on 27 Mar 2011, 03:18 PM
I've tried using the DateTimePicker in my grid, I've tried inline and popup. Using fiddler it seems that although the editor shows for my column;

3/27/2011 08:35pm 

When I edit the cell, changing the time to midnight, the posted data is incorrect. 

DateEffective":"\/Date(1299980576000)\/","

That comes out as 1/2/0001 12:01. 
0
Accepted
Georgi Krustev
Telerik team
answered on 28 Mar 2011, 08:39 AM
Hello,

The aforementioned issue is a known bug. It was fixed after official release of Q1 2011. I have attached the modified JavaScript file to this message. You just need to change it locally and the problem should be fixed. 

Regards,

Georgi Krustev
the Telerik team
0
bhavya
Top achievements
Rank 1
answered on 20 Jan 2012, 11:37 AM
my model class will be
 
 
  [DisplayName("Enrollment Start Date")]
        [DataType(DataType.Date)]
        [UIHint("DateTemplate"), Required]
 
        public DateTime startDate
        {
            get;
            set;
        }
        [DisplayName("Enrollment End Date")]
        [DataType(DataType.Date)]
        [UIHint("DateTemplate"), Required]
 
        public DateTime EndDate
        {
            get;
            set;
        }
 
 
 
and  the aspx page will be
 
 
 
 
 
<%= Html.Telerik().Grid<EnrollmentSystem.Models.GridVillage>()
       .Name("Grid")
       .DataKeys(keys => { keys.Add(p => p.VillageName); })
       .Scrollable(scrolling => scrolling.Enabled(true))
       .ToolBar(commands => {
           commands.Insert();
           commands.SubmitChanges();
       })
       .DataBinding(dataBinding => dataBinding.Ajax()
                                           .Select("_GetVillageDetails", "RoadMap")
                   .Update("_SaveBatchEditing", "RoadMap")
                    
     )
      .Columns(columns =>
      {
          columns.Bound(p => p.VillageName).Width(100).Title("Village Name"+"*");
          columns.Bound(p => p.Families).Width(100).Format("{0:c}").Title("No.Of Families" + "*");
         // columns.Bound(p => p.Target).Width(80).Format("{0:N}").Title("Target"); ;
          columns.Bound(p => p.Kits).Width(100).Title("No.Of Kits" + "*");
          columns.Bound(p => p.Team).Width(100).Title("Team Name");
          columns.Bound(p => p.Days).Width(100).Title("No.Of Days" + "*");
          columns.Bound(p => p.PDO).Width(80).Title("PDO Name");
          columns.Bound(p => p.startDate).Width(160).Title("Enrollment Start Date" + "*").Format("{0:dd/MM/yyyy}").HtmlAttributes(new { Style = "text-align:left" });
            
          columns.Bound(p => p.EndDate).Width(160).Title("Enrollment End Date" + "*").Format("{0:dd/MM/yyyy}").HtmlAttributes(new { Style = "text-align:left" });
          columns.Bound(p => p.PDOMobile).Width(100).Title("PDO Mobile");
          columns.Bound(p => p.Venue).Width(100).Title("Venue" + "*");
          columns.Bound(p => p.FKOName).Width(100).Title("FKO Name" + "*");
          columns.Bound(p => p.FKOmobile).Width(100).Title("FKO Mobile");
          columns.Bound(p => p.Operatorname).Width(100).Title("Operators Name");
          columns.Bound(p => p.Operatornumber).Width(120).Title("Operators Number");
          columns.Bound(p => p.TechiPersoname).Width(150).Title("Technical Person Name");
          columns.Bound(p => p.TechiPersoNumer).Width(150).Title("Technical Person Number");
           
          columns.Command(commands => commands.Delete()).Width(90).Title("Delete");     
      })
       
       
           
    .ClientEvents(events =>
              events.OnDataBinding("Grid_onDataBinding").OnError("Grid_onError"))
 
               
                            .Editable(editing => editing.Mode(GridEditMode.InCell).DefaultDataItem(new GridVillage
     {
         startDate = DateTime.Today,
         EndDate = DateTime.Today
     }))
 
 
 
                             .Pageable(pagecount => pagecount.PageSize(CrossCutting_Constants.GridPageSize))
    .Scrollable()
    .Sortable()
     %> 
 
 
 
 
 
ascx page will be
 
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DateTime>" %>
<%= Html.Telerik().DatePickerFor(m => m) %>
 
and i am working batch editing of a grid,, i have used date picker in side the grid for the two columns namely Enrollment Start and Enrollment End Date ,,I have written a ascx page for the date picker but still i am not able to c the date picker..
 
i am using q1 version of the telerik ddl,,i have changed the version of telerik editing.min.js  as u said before script but still no luck cn any one tell me where i am going wrong...
0
sathish kumar
Top achievements
Rank 1
answered on 14 Feb 2012, 12:04 PM
Am struggling witht the same issue... please help me on this
Tags
Date/Time Pickers
Asked by
Andre Jones
Top achievements
Rank 1
Answers by
Terry Burns-Dyson
Top achievements
Rank 1
Georgi Krustev
Telerik team
bhavya
Top achievements
Rank 1
sathish kumar
Top achievements
Rank 1
Share this question
or