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

Opening on the DateRange

5 Answers 114 Views
DateRangePicker
This is a migrated thread and some comments may be shown as answers.
Nicolas
Top achievements
Rank 1
Iron
Nicolas asked on 28 May 2019, 07:17 PM

When editing a form with data, when I click the control to "EDIT" my saved date range selection it's opening on Todays date instead of my date range selection.

Any idea how to resolve this?

5 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 31 May 2019, 12:47 PM
Hi Nicolas,

Currently the dateView will be opened with the today's date view, but after the initialization of the widget you can set the dataView._current value to a particular date:
$("#pickerid").data("kendoDateRangePicker").dateView._current = new Date(2015, 2,2)

You can also log this as a feature request in our public portal:

Regards,
Konstantin Dikov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Nicolas
Top achievements
Rank 1
Iron
answered on 31 May 2019, 01:20 PM

I will request this as a feature.

The code you just gave me is half way working. It seems that it shift evrything by a month after as you see in my capture. Something must be wrong I guess. My event start is in august and it open on Septembre.

$(document).ready(function () {
        $("#daterangepicker").data("kendoDateRangePicker").dateView._current = new Date(@Model.StartDate.Year, @Model.StartDate.Month,@Model.StartDate.Day);
    });

 

0
Viktor Tachev
Telerik team
answered on 05 Jun 2019, 08:29 AM
Hi Nicolas,

The reason for the offset by a month is that the JavaScript Date is using zero-based indexes for the months. Thus, the index of August is 7. 

In order to resolve this I suggest subtracting one from StartDate.Month when setting the current view for the DateRangePicker:

$(document).ready(function () {
    $("#daterangepicker").data("kendoDateRangePicker").dateView._current = new Date(@Model.StartDate.Year, @Model.StartDate.Month-1, @Model.StartDate.Day);
});

With that said, I also created a feature request in our portal on your behalf. Based on the votes it gathers we will be able to prioritize it with the other requests so it can be included in the planning.


Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Nicolas
Top achievements
Rank 1
Iron
answered on 05 Jun 2019, 01:31 PM
Hi, Thank you and figured that out already but still a bit counter intuitive while mixing MVC/Core and JS :-)
0
Viktor Tachev
Telerik team
answered on 10 Jun 2019, 10:11 AM
Hello Nicolas,

I understand your position.

The reason behind this is that the MVC and Core components are actually wrappers of the Kendo UI for jQuery widgets. Thus, when a customization of the default behavior is required it is necessary to use JavaScript in order to change the settings of the underlying widget. 


Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
DateRangePicker
Asked by
Nicolas
Top achievements
Rank 1
Iron
Answers by
Konstantin Dikov
Telerik team
Nicolas
Top achievements
Rank 1
Iron
Viktor Tachev
Telerik team
Share this question
or