Hide weekend functionality?

5 posts, 0 answers
  1. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 12 Jul 2012 Link to this post

    Hi All,

    Is there any Hide Weekend type functionality available on the scheduler yet? 

    Regards,

    Jon
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Jul 2012 Link to this post

    Hi Jon,

    I suppose you want to hide the LastDayOfWeek in the RadScheduler when the SelectedView is WeekView. Following is the sample code.

    CSS:
    <style type="text/css">
      .rsDisabled
       {
         width: 0px;
       }
    </style>

    C#:
    protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e)
      {
        if ( e.TimeSlot.Start.DayOfWeek == RadScheduler1.LastDayOfWeek && RadScheduler1.SelectedView == SchedulerViewType.WeekView)
          e.TimeSlot.CssClass = "rsDisabled";
      }

    JS:
    <script type="text/javascript">
        var specialDaysIndexes = new Array();
        function pageLoad() {
            debugger;
            if ($find('<%=RadScheduler1.ClientID %>').get_selectedView() == Telerik.Web.UI.SchedulerViewType.WeekView) {
                var $ = $telerik.$;
                $('.rsDisabled').each(function (i) {
                    specialDaysIndexes.push($(this).index());
                });
                for (x in specialDaysIndexes) {
                    $($(".rsHorizontalHeaderTable th", $find('<%=RadScheduler1.ClientID %>').get_element()).get(specialDaysIndexes[x])).css("width", "0px")
                }
                specialDaysIndexes = [];
            }
        }
    </script>

    Hope this helps.

    Regards,
    Princy.
  3. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 13 Jul 2012 Link to this post

    Hi Princy

    Many thanks for that.  Yes Saturday and Sunday need to be hidden.

    The code seems to all run fine and in the main part the days get hidden nicely however the header doesn't have the saturday and sunday hidden, the jquery doesn't seem to function properly - it does run and looking at the specialdaysindexes I can see the it has 0 and 6 repeated many times so obviously it's trying to do something.  My jquery ability is 0 at the moment so debugging it is somewhat tricky though :(

    Is there another way to hide the header days?

    Best Regards,

    Jon
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 17 Jul 2012 Link to this post

    Hi Jon,

    In general, this is not supported functionality and workarounds you use will have limitations. That said, you can try the following modification, but I advise you to fully test it and make sure it does not fail for some scenarios that you will use:
    <head id="Head1" runat="server">
      
        <script type="text/javascript" src="jquery.js"></script>
      
        <style type="text/css">
      
              
      
            /*Comment this style*/
      
            /*.rsDisabled
      
            {
      
                width: 0px;
      
            }*/
      
        </style>
      
    </head>
      
    <body>
      
        <telerik:radcodeblock id="RadCodeBlock1" runat="server">
      
            <script type="text/javascript">
      
      
      
                var specialDaysIndexes = new Array();
      
                var aux = 1;
      
                var appoinmentCellWasResized = false;
      
                var planboardID = '<%=RadScheduler1.ClientID %>';
      
      
      
                function pageLoad() {
      
                    var $ = $telerik.$;
      
                    var scheduler = $find('<%=RadScheduler1.ClientID %>');
      
                    if ($find('<%=RadScheduler1.ClientID %>').get_selectedView() == 4) {
      
      
      
                        var tds = $('table.rsAllDayTable tr.rsAllDayRow .rsDisabled');
      
                        var ths = $(".rsHorizontalHeaderTable th ");
      
      
      
                        tds.each(function (i) {
      
                            specialDaysIndexes.push($(this).index());
      
                        });
      
                          
      
      
      
                        for (x in specialDaysIndexes) {
      
                            //$(ths.get(specialDaysIndexes[x])).css("width", "0px");
      
                            $(ths.get(specialDaysIndexes[x])).remove();
      
                        }
      
                        tds.remove();
      
      
      
                        scheduler.repaint();
      
                        specialDaysIndexes = [];
      
                        if (!appoinmentCellWasResized) {
      
                            $('.rsApt').each(function () {
      
                                $(this).css("width", $(this).width() - 10);
      
                            });
      
                            appoinmentCellWasResized = true;
      
                        }
      
                    }
      
                }
      
      
      
            </script>
      
    </telerik:radcodeblock>


    All the best,
    Peter
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Jon
    Jon avatar
    813 posts
    Member since:
    Oct 2008

    Posted 23 Jul 2012 Link to this post

    Hi Peter,

    Many thanks for that.  I've given a quick go and it didn't seem to work so I'll have a look after my holiday - don't want to introduce a new issue before then :)

    Thanks for our help.

    Regards,

    Jon
Back to Top