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

Only Enable Quarter in Year View

3 Answers 250 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Lucy
Top achievements
Rank 1
Lucy asked on 04 Apr 2019, 02:08 PM

Hello,

We have a DatePicker which has the 'Year' view so you can only select months. We wish to only allow the user to select Quarters (March, June, Sept & Dec). 

I can only seem to disable by days of week. Is there anyway to disable by months of year?

Thank you

Lucy

3 Answers, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 08 Apr 2019, 08:20 AM
Hello, Lucy,

The Kendo UI Calendar and DatePickers do not have a built-in way to disable months in year view, however, it is possible to do that programmatically when the widget triggers its open event, for example:

https://dojo.telerik.com/@bubblemaster/oPaLuCUL

open: function(e){
  var calendar = e.sender.dateView.calendar;
  var monthCells = calendar.element.find("tr td").filter(function(i,cell){
    var $cell = $(cell);
    if($cell.text() === "Mar" || $cell.text() === "Jun"){
      $cell.addClass("k-state-disabled")
        .click(function(e){
        e.stopImmediatePropagation();
      });
    }
  });
}

We actually have an open feature request that you can vote for. The most popular feature requests are considered for implementation in the planning process:

https://feedback.telerik.com/kendo-jquery-ui/1360066-add-support-for-disabled-months-and-years-in-date-picker

Let me know in case you need further assistance.

Kind Regards,
Alex Hajigeorgieva
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
Lucy
Top achievements
Rank 1
answered on 10 Apr 2019, 02:37 PM

Thank you Alex.

This fix works fine on the first 'year' view but if you move to the following or previous year, those months aren't disabled.

Is there another approach?

Thank you

Lucy

0
Alex Hajigeorgieva
Telerik team
answered on 11 Apr 2019, 11:59 AM
Hello, Lucy,

Thank you for pointing out the issue during navigation. To get the same approach to work for both the initial opening of the Kendo UI DatePicker calendar as well as during the calendar navigation, we need to execute the same logic in the calendar navigate event:

https://dojo.telerik.com/IFEbIgiH

Kind Regards,
Alex Hajigeorgieva
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
Date/Time Pickers
Asked by
Lucy
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Lucy
Top achievements
Rank 1
Share this question
or