Only Enable Quarter in Year View

4 posts, 0 answers
  1. Lucy
    Lucy avatar
    17 posts
    Member since:
    Nov 2016

    Posted 04 Apr Link to this post

    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

  2. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    773 posts

    Posted 08 Apr Link to this post

    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.
  3. Lucy
    Lucy avatar
    17 posts
    Member since:
    Nov 2016

    Posted 10 Apr in reply to Alex Hajigeorgieva Link to this post

    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

  4. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    773 posts

    Posted 11 Apr Link to this post

    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.
Back to Top