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

Default highlighted range

2 Answers 45 Views
DateRangePicker
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 02 Aug 2019, 11:53 AM

Current Month August:

                @(Html.Kendo().DateRangePicker()

                                                      .Name("daterangepicker3")
                                                      .Format("MM/dd/yyyy")
                                                      .Range(r => r.Start(DateTime.Now.AddMonths(-1)).End(DateTime.Now.AddMonths(-1).AddDays(10)))
                                                      .HtmlAttributes(new { style = "width: 100%", title = "daterangepicker3" })
                )

When the default Range is last month, clicking the date boxes, shows August, not July where the highlighted range is.   Is there away to set the start month?

2 Answers, 1 is accepted

Sort by
0
Denitsa
Telerik team
answered on 06 Aug 2019, 07:19 AM
Hello Peter,
You could set the start month in the calendar by using the navigate method of the calendar.

In your example that could be done by adding the following:

@(Html.Kendo().DateRangePicker()
....
<script>
    $(function () {
        var today = new Date();
        var shownStartDate = new Date(today.getFullYear(),(today.getMonth() - 1),today.getDate())
        var picker = $('#daterangepicker3').data('kendoDateRangePicker')
 
        picker.dateView._calendar()
        picker.dateView.calendar.navigate(shownStartDate)
    })
</script>


Regards,
Denitsa
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
Peter
Top achievements
Rank 1
answered on 06 Aug 2019, 11:23 AM

Thanks, that got me to closer to this:

    var picker = $('#daterangepicker3').data('kendoDateRangePicker');
    picker.dateView._calendar();
    picker.dateView.calendar.navigate(picker.range().start);

Tags
DateRangePicker
Asked by
Peter
Top achievements
Rank 1
Answers by
Denitsa
Telerik team
Peter
Top achievements
Rank 1
Share this question
or