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

DatePickder change evnt send to controller

3 Answers 222 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Maurice
Top achievements
Rank 1
Veteran
Maurice asked on 27 Sep 2016, 02:51 PM

Hi,

I have a view with a standalone datepicker (controller/index(DateTime? date))

@(Html.Kendo().DatePicker()
      .Name("datePicker")
      .Events(e => e.Change("change"))
      )

Now I want to have a change event to go to the same page (controller/index(date = result of the datepicker)

function change() {
//something
}

3 Answers, 1 is accepted

Sort by
0
Eduardo Serra
Telerik team
answered on 27 Sep 2016, 03:03 PM
Hello Maurice,

You can implement an ajax call inside the change function and send this.value to the controller like this:

01.function change() {
02.        var date = this.value();
03. 
04.        var action = '@Url.Action("yourAction", "yourController")';
05.        var url = kendo.format("{0}/{1}",
06.            action,
07.            date);
08. 
09.        $.ajax({
10.            url: url,
11.            success: function (Address) {
12.               ...your custom success logic
13.        });
14.    }

I hope this helps!

Regards,
Eduardo Serra
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Maurice
Top achievements
Rank 1
Veteran
answered on 28 Sep 2016, 07:47 AM

This does work but the url will become

url = "/controller/action/Thu Sep 01 2016 00:00:00 GMT+0200 (W. Europe Daylight Time)"

Which isn't a nice url.

I hope to insert the date into

public ActionResult Index(DateTime? startDate)

Is this possible?

 

Maurice

 

 

public ActionResult Index(DateTime? startDate)

0
Eduardo Serra
Telerik team
answered on 28 Sep 2016, 05:10 PM
Hello Maurice,

Kendo UI is capable of manipulating date objects for situations such as these; I encourage you to take a look at our Date Formatting guide and choose a format that works for you and can be passed to the controller in a more elegant way.

I hope this helps!

Regards,
Eduardo Serra
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Date/Time Pickers
Asked by
Maurice
Top achievements
Rank 1
Veteran
Answers by
Eduardo Serra
Telerik team
Maurice
Top achievements
Rank 1
Veteran
Share this question
or