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

Adding onChange Event to DatePicker

1 Answer 579 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 03 Mar 2016, 12:13 AM

I'm trying to add an onChange event to the Kendo DatePicker and noticed that there is not an easy way to go about doing this, I unfortunately. 

I was able to add an override by using jQuery but I can only get this to work if I know the name of the datepicker. I'm providing an example of this below for reference. 

<!-- [ begin ] invoke onChange event -->


<script type="text/javascript">
    $(document).ready(function () {
        function onChanger() {
            alert("Change :: " + kendo.toString(this.value(), 'd')); // show the value

            document.forms['submitForm'].submit(); // submit the form
        }

        $("#datepicker").kendoDatePicker({
            change: onChanger
        }
        );
    }); 
</script>

<input id="datepicker" name="datepickers" />

<!-- [ end ] invoke onChange event -->

My problem is I'm looping through items which dynamically are building these datepickers.

So my code looks like this:

<code>

  @(Html.Kendo()
                                                          .DatePicker()
                                                          .Name("AllTeachersObjectives_" + rec.CalendarGroupID)
                                                          .Value(rec.AllTeachersObjectives)
                                                          .Max(DateTime.Now.AddYears(10))
                                                          .Events(e => e.Change("startChange"))
                                                )

</code>

How can I dynamically invoke the onChange event from using a name of a datePicker that is dynamic?

Any help would be greatly appreciated!! 

TIA

- Dave

 

 

 

1 Answer, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 07 Mar 2016, 08:26 AM
Hi Dave,




You may try the following:

http://w3foverflow.com/question/in-mvc-dynamically-generated-kendo-datepicker-onchange-event-validation/

Regards,
Helen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Date/Time Pickers
Asked by
Dave
Top achievements
Rank 1
Answers by
Helen
Telerik team
Share this question
or