Kendo Grid DatePicker Editor Template DateTime Change Value not working

2 posts, 0 answers
  1. Kyriacos
    Kyriacos avatar
    1 posts
    Member since:
    Feb 2014

    Posted 28 Feb 2014 Link to this post

    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
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1444 posts

    Posted 04 Mar 2014 Link to this post

    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!
Back to Top