最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HideDisable Weekends from Kendo UI dateTimepicker - Stack Overflow

programmeradmin1浏览0评论

I am using kendo DateTimePicker and just don't want user to select from Weekends.

I have tried assigning MonthTemplate() aproach as follows:

@(Html.Kendo().DateTimePickerFor(m => Data)
                       .MonthTemplate("# if (isWeekDay(data.date)) { #" +
                                                    "#= data.value #" +
                                                    "# } #" 
                                                    )  
    function isWeekDay(date)
        {
            var day = date.getDay();

            return (day % 6 != 0);
        }

But it helped me for just not displaying the Date in the Widget, but user still able to select it by clicking over the blank Cell in the Month Template.

Tried using Validation handling onChange Event and (e.StopPropagation for not closing the dropdown), but still its working.

Is it possible or doing efforts invain?

Thanks Sumeet

I am using kendo DateTimePicker and just don't want user to select from Weekends.

I have tried assigning MonthTemplate() aproach as follows:

@(Html.Kendo().DateTimePickerFor(m => Data)
                       .MonthTemplate("# if (isWeekDay(data.date)) { #" +
                                                    "#= data.value #" +
                                                    "# } #" 
                                                    )  
    function isWeekDay(date)
        {
            var day = date.getDay();

            return (day % 6 != 0);
        }

But it helped me for just not displaying the Date in the Widget, but user still able to select it by clicking over the blank Cell in the Month Template.

Tried using Validation handling onChange Event and (e.StopPropagation for not closing the dropdown), but still its working.

Is it possible or doing efforts invain?

Thanks Sumeet

Share Improve this question asked May 22, 2013 at 19:12 SumeetSumeet 9151 gold badge14 silver badges32 bronze badges 2
  • Looking for something like we have in Jquery dateTimepicker: $("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends }); – Sumeet Commented May 22, 2013 at 19:33
  • Friends, is somethign wrong with my question. Its been more than 24 hrs and this is not able to catch even a single attention? Am I doing things pletely wrong or there is something wrong in stating my problem. Please guide me.. – Sumeet Commented May 23, 2013 at 21:03
Add a ment  | 

1 Answer 1

Reset to default 6

Hope you still need help about your question. This is a way to disable click on weekends.

.kendoDatePicker({
    open: function() { $('.k-weekend a').bind('click', function() { return false; }); }
});

.k-weekend is the class associated to weekend cells. So, it's easy to disable the click on those cells. It's also possible to put some CSS to change the aspect of those cells.

Hope this will help. Laurent

发布评论

评论列表(0)

  1. 暂无评论