user3363863
user3363863

Reputation: 23

MVC kendo timepicker value null when i edit kendo grid

i have using inline editing in mvc datagrid. when i select edit for editing record TimePicker value is null.

**In Grid**             
 columns.Bound(p=>p.TimeRequired).EditorTemplateName("GridTimePicker").Title("Time");**     

 **Editor Template (GridTimePicker.cshtml):**          
  @model DateTime?      
  @(                            
   Html.Kendo().TimePickerFor(m=>m).Name("GridTimePicker").Interval(15)    
   )

how to solve this problem? thanks in advance.

Upvotes: 0

Views: 2367

Answers (2)

Shazhad Ilyas
Shazhad Ilyas

Reputation: 1193

****Editor Template*******

@model DateTime?
@(Html.Kendo().DatePicker()
    .Name("TimeRequired") //name should be same as property
    .Value(Model == null ? DateTime.Now.Date : ((DateTime)@Model).Date)
)

***************Grid*******

 // will print the date in "28/01/2014" style...
    columns.Bound(p=>p.TimeRequired).EditorTemplateName("GridTimePicker").Title("Time")
    .ClientTemplate("#= kendo.toString(TimeRequired,'d') #")

regards

Shaz

Upvotes: 0

Atanas Korchev
Atanas Korchev

Reputation: 30661

You should not set the Name() when using TimePickerFor:

@(Html.Kendo().TimePickerFor(m=>m).Interval(15))

Upvotes: 2

Related Questions