Those approaches don't work:

dateSelectedFrom = $("#datepickerFrom").value - undefined
dateSelectedFrom = $("#datepickerFrom").value() - object has no method value()

I know that I can use this.value() and it is works fine, but the method onDateSelectedFromCalendar is used by a different dateTimePicker control (I have several on the page)

<input id="datepickerFrom" value="10/10/2011" />

   $("#datepickerFrom").kendoDatePicker({
            change: onDateSelectedFromCalendar
        });

   function onDateSelectedFromCalendar(e) {
        dateSelectedFrom = $("#datepickerFrom").value;
    }

Documentation doesn't specify any other options http://docs.telerik.com/kendo-ui/api/web/datepicker

有帮助吗?

解决方案

With the Kendo object you have to use data like:

var d = $("#datepickerFrom").data("kendoDateTimePicker").value();

See the documentation here.

其他提示

You can have all the datepickers calling the same onChange event using the below:

function onDateSelectedFromCalendar(e) {
    dateSelectedFrom = e.sender.value();
}

if you wanted to be able to distinguish which element triggered the function you could use:

e.sender.element[0].id

which will give you the Id of the element.

Lastly

e.sender

will give you the same as

$('#datepickerFrom').data().kendoDatePicker

Check their DatePicker api Here

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top