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

Kendo Grid DatePicker Editor Template DateTime Change Value not working

1 Answer 394 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kyriacos
Top achievements
Rank 1
Kyriacos asked on 28 Feb 2014, 04:01 PM
Consider the following code i want to set the grid datePicker column empty if date validation fails WorkOrderDate< task date , any help would be higly appreciable.


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

columns.Bound(c => c.WorkOrderDetailsDate).Title("Estimated Start Date").EditorTemplateName("WorkOrderDetailsDate")

***********Editor**************

@model DateTime?
@(Html.Kendo().DatePicker()
.Name("WorkOrderDetailsDate")
.Value(Model == null ? DateTime.Now.Date : ((DateTime)@Model).Date)
.Events(d=>d.Change("TaskDateValidate"))
)

*************JavaScript***********
function TaskDateValidate(e)
{

     if ($("#workOrder_EstStartDate").val() != null && $("#workOrder_EstStartDate").val() != "") {
    var workDate = kendo.parseDate($("#workOrder_EstStartDate").val());
    var taskDate = kendo.parseDate(kendo.toString(this.value(), 'd'));

       if (taskDate < workDate)
       {

       showMessage("Task date should be after work order Date");
        this.value(""); <-----this is not working want to set to empty to force user to select date again
           this.value("28/02/2014");<---this is not working as well...
       }
}


please advise on this problem
reagrds
Shaz

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 04 Mar 2014, 01:14 PM
Hi Shaz,

You can achieve that behavior by initializing a Kendo UI Validator and specifying the custom rules that should be applied. Then subscribe for the Grid's save event and once the event is triggered - call the Validator's validate method, as shown in this JavaScript example.

Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Kyriacos
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or