5 Replies Latest reply: Jul 12, 2013 6:54 AM by ABD - DBA RSS

    Calender form - hiding weekends Saturday and Sunday

    ABD - DBA

      I have a Calendar page and I want it to only show business days, hiding the weekends.  I found some code that halfway worked in this thread:

      https://forums.oracle.com/thread/684334

       

      But as it's old, I figured I would start another as the code isn't working entirely.  I placed it in the header region of the Calendar and it works when you initially open the page, but if you click the [Monthly] button, Saturday and Sunday re-appear until you refresh the page.

       

      <script type="text/javascript">
      //<![CDATA[

         $(document).ready(function(){
            $tblRows = $('table.t13Calendar tr');
            $tblRows.each(function() {
               $tblDatas = $(this).children('td, th');
               $tblDatas.eq(0).remove();
               $tblDatas.eq(6).remove();
            });
         });

      //]]>
      </script>

        • 1. Re: Calender form - hiding weekends Saturday and Sunday
          jrimblas

          When you click the buttons the Calendar code changes with a PPR (Partial Page Refresh) thus HTML is all new and different. The code only runs once (on document ready)

           

          So... add a Dynamic action that runs After Refresh of your region and runs the code (minus the script, the CDATA and the document .ready).

           

          $tblRows = $('table.t13Calendar tr');
          $tblRows.each(function() {
          $tblDatas = $(this).children('td, th');
          $tblDatas.eq(0).remove();
          $tblDatas.eq(6).remove();
          });
          

           

          I'm surprised it works because it has the t13Calendar class in there, that's theme specific, you must be using the same theme.

           

          Thanks

          -Jorge

          http://rimblas.com/blog/

          • 2. Re: Calender form - hiding weekends Saturday and Sunday
            ABD - DBA

            Thanks that did it.  For those using this in the future, you need to check what your calendar is called.  That code was taken from the other thread, my calendar was actually just Calendar, not t13Calendar.

             

            thanks

            Drew

            • 3. Re: Calender form - hiding weekends Saturday and Sunday
              jrimblas

              Glad it worked!  Yes, exactly the Calendar "id" or "class" may be specific to the template you're using.

               

              I should have mentioned, I think you can get rid of the original code all together because the DA will take care of it.  I could be wrong, but I think the after refresh will fire when the calendar renders the first time. If it does not just check it to run On Load.  That way the code is just in one place.

               

              Thanks

              -Jorge

              • 4. Re: Calender form - hiding weekends Saturday and Sunday
                ABD - DBA

                Still need it in the header, as it only works on refresh.  I've mistakenly. had it run twice, by placing it in two regions, and it will then hide Monday.  I have since change the Calendar to start on Monday and changed the code to:

                 

                1. $tblRows = $('table.t13Calendar tr'); 
                2. $tblRows.each(function() { 
                3. $tblDatas = $(this).children('td, th'); 
                4. $tblDatas.eq(5).remove(); 
                5. $tblDatas.eq(6).remove(); 

                }); 

                 

                chandge line 4 from 0 to 5, so it removes the last two columns, so if it does run twice, it doesn't have anything to remove.

                • 5. Re: Calender form - hiding weekends Saturday and Sunday
                  jrimblas

                  ABD-DBA wrote:

                   

                  if it does run twice, it doesn't have anything to remove.

                  That's correct.

                   

                  Interesting, the Calendar must not be quite ready "on load" yet.  Hmmm...

                   

                  Well, glad you got it working.

                  -Jorge