0

When Change event in DatePicker KendoUI occurs, I can't get .ajax() method to work - method is not invoked. Please have a look into it.

<label for="start">Start Date:</label>
@(Html.Kendo().DatePicker()
    .Name("start")
    .Value(fromDate)
    .Min("01/01/2010")
    .Max("01/01/2015")
    .Events(e => e.Change("startChange"))
)

<label for="end">End Date:</label>
@(Html.Kendo().DatePicker()
    .Name("end")
    .Value(toDate)
    .Min("01/01/2010")
    .Max("01/01/2015")
    .Events(e => e.Change("endChange"))
)

<script type="text/javascript">
   function startChange() {

        var startDate = this.value();
        var endDate = $("#end").data("kendoDatePicker").value();

        $.ajax({
            url: "/Home/SaleOrders",
            type: "POST",
            data: {
                fromDate: kendo.toString(startDate, "d"),
                toDate: kendo.toString(endDate, "d")
            },
            success: function (response) {
            },
            error: function (e) {
                alert("error");
            }
        });

        @*$.post('@Url.Action("SaleOrders", "Home")', { fromDate: startDate, toDate: $("#end").val() });  - I also tried with post method - but no luck*@
    }

Controller method:

public ActionResult SaleOrders(DateTime? fromDate, DateTime? toDate)
        {
            // ... get the list of orders here
            return View(model);
        }

I tried this method with [HttpPost] attribute but it doesn't help.

Selman Genç
  • 100,147
  • 13
  • 119
  • 184
Dmitry Stepanov
  • 2,776
  • 8
  • 29
  • 45

0 Answers0