This is a migrated thread and some comments may be shown as answers.
Edit DateTime column and OnSave()
2 Answers 36 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Helene Lach
Top achievements
Rank 1
Helene Lach asked on 21 Apr 2011, 07:24 PM

I am using a grid to edit a model a StarDate and EndDate defined as DateTime. The grid is Ajax-bound and uses in-line editing. If I try to edit (or add) a record, the grid correctly displays the dates using the Telerik DateTime editor template. I am wiring up some javascript to intercept the save event. The save event gets invoked. The issue is that e.values does not contain any entries for the DateTime properties - all the other properties get passed correctly. If I use a Date type instead (decorating the property with [DataType(DataType.Date)]) in the model) everything works fine and the value gets passed down correctly. If I disable the DateTime editor template and use a standard text box, everything works fine.

Is there something that needs to be done to the DateTime editor template to make it work properly with javascript?

Here is the code I have for the DateTime editor template:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DateTime?>" %>
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
  
<%= Html.Telerik().DateTimePicker()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .Value(Model > DateTime.MinValue? Model : DateTime.Today)
%>

 
Model:

public class CouponModel
       {
           [HiddenInput(DisplayValue = false)]
           public int CouponId { get; set; }
           public DateTime StartDate { get; set; }
           [DataType(DataType.Date)]
           public DateTime EndDate { get; set; }
        }

Javascript OnSave():

function onSourceCodeSaleRulesGridSave(e) { 
var values = e.values; 
  
alert(values['Section.StartDate']); // This is undefined 
alert(values['Section.EndDate']); // This works
}

Note that I use MVC3 with Razor.

Thanks in advance for your help.

2 Answers, 1 is accepted

Sort by
0
Helene Lach
Top achievements
Rank 1
answered on 21 Apr 2011, 08:43 PM
I just upgraded to the latest internal build (2011.1.419) and it solved the issue!
0
lahyaw galak
Top achievements
Rank 1
answered on 26 Apr 2011, 10:05 AM
how to get the internal build?
Tags
Grid
Asked by
Helene Lach
Top achievements
Rank 1
Answers by
Helene Lach
Top achievements
Rank 1
lahyaw galak
Top achievements
Rank 1
Share this question
or