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

Data Validation on Kendo Grid with Editor Template on Date field

1 Answer 213 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gomathy
Top achievements
Rank 1
Gomathy asked on 28 Oct 2015, 08:35 PM

Hello,

I'm having some problems with data validation with the kendo grid. I've set up the Grid to use a model that has several fields. I'm most interested in the DateTime field for which I've set up data annotations to help with validation. I've labeled the field to be Required, to use a regular RegularExpression, and I've also specified an EditorTemplate called "BeginDateEditor". The editing mode is set up to be InLine. The problem occurs when I actually try to edit the field. The data validation doesn't seem to work. The editing will allow the user to close the cell with no value where in fact it should notify the user that there is a problem and keep the cell open for editing. I've attached a sample project to illustrate the problem. 

Thank you.

1 Answer, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 30 Oct 2015, 12:36 PM

Hello Gomathy,

The issue you have described is caused by incorrect configuration of the EditorTemplate. You should instead use DataPickerFor extension method. This way the metadata associated with property will be retrieved and applied to  widget declaration. 

@using Kendo.Mvc.UI
@model DateTime
 
@(Html.Kendo().DatePickerFor(m => m)
        .Min(DateTime.Now.AddDays(-90))
        .Max(DateTime.Now)
)

Regards,
Rosen
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Gomathy
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or