Loading ...
Sorry, an error occurred while loading the content.

Custom calendar renderers not working?

Expand Messages
  • Justin Ashworth
    I would like to create a calendar which does not allow selection on certain holidays. I tried to use the YAHOO.widget.Calendar.renderBodyCellRestricted
    Message 1 of 4 , Feb 14, 2006
    • 0 Attachment
      I would like to create a calendar which does not allow selection on
      certain holidays. I tried to use the
      YAHOO.widget.Calendar.renderBodyCellRestricted renderer, but it did
      not work. So then I tried to write a custom renderer which would just
      place an "H" in the date of the holiday. Can somebody look at the
      code below and see my mistake? Thank you so much!

      renderCellHoliday = function(workingDate, cell) {
      cell.innerHTML = "";
      cell.appendChild(document.createTextNode("H"));
      return YAHOO.widget.Calendar_Core.STOP_RENDERER;
      }

      function init() {
      cal1 = new YAHOO.widget.Calendar("cal1","cal1Container");
      cal1.addRenderer("2/21/2006", renderCellHoliday);
      cal1.render();
      }

      Thanks,

      Justin
    • Steven Peterson
      Justin, I tried getting your example to work, and at first I was baffled, but then I caught a small typo. The constant that you want to use to prevent the
      Message 2 of 4 , Feb 14, 2006
      • 0 Attachment

        Justin,

         

        I tried getting your example to work, and at first I was baffled, but then I caught a small typo. The constant that you want to use to prevent the render stack from executing the default renderer is STOP_RENDER, rather than STOP_RENDERER. Once I changed that, it worked without a problem.

         

        I noticed that you said that you couldn’t get renderBodyCellRestricted to work. Can you provide more details on the problem you had with it? If you modify your init code as follows, it should work fine for you:

         

        function init() {

                                cal1 = new YAHOO.widget.Calendar("cal1","cal1Container");

                                cal1.addRenderer("2/21/2006", cal1.renderBodyCellRestricted);

                                cal1.render();

                    }

         

        Assuming you’re pointing to the default CSS, it should render the date with a strike-through. If you need any more assistance, don’t hesitate to let me know. J

         

        Thanks!

         

        Steven Peterson

        Web Developer, Platform Engineering

        Yahoo!


        From: ydn-javascript@yahoogroups.com [mailto:ydn-javascript@yahoogroups.com] On Behalf Of Justin Ashworth
        Sent: Tuesday, February 14, 2006 7:59 PM
        To: ydn-javascript@yahoogroups.com
        Subject: [ydn-javascript] Custom calendar renderers not working?

         

        I would like to create a calendar which does not allow selection on
        certain holidays.  I tried to use the
        YAHOO.widget.Calendar.renderBodyCellRestricted renderer, but it did
        not work.  So then I tried to write a custom renderer which would just
        place an "H" in the date of the holiday.  Can somebody look at the
        code below and see my mistake?  Thank you so much!

        renderCellHoliday = function(workingDate, cell) {
            cell.innerHTML = "";
            cell.appendChild(document.createTextNode("H"));
            return YAHOO.widget.Calendar_Core.STOP_RENDERER;
        }

        function init() {
            cal1 = new YAHOO.widget.Calendar("cal1","cal1Container");
            cal1.addRenderer("2/21/2006", renderCellHoliday);
            cal1.render();
        }

        Thanks,

        Justin




      • Justin Ashworth
        Hi Steven, Thank you very much for your help - I got it to work. For some reason I read STOP_RENDER as STOP_RENDERER in the API docs. With your help, my
        Message 3 of 4 , Feb 15, 2006
        • 0 Attachment
          Hi Steven,

          Thank you very much for your help - I got it to work. For some reason
          I read STOP_RENDER as STOP_RENDERER in the API docs. With your help,
          my holiday example now works. The reason renderBodyCellRestricted
          didn't work is because I was treating it as a static function
          reference by using "YAHOO.widget.Calendar.renderBodyCellRestricted"
          verbatim rather than "cal1.renderBodyCellRestricted". I don't even
          know if there's such a thing as a static function reference in
          Javascript - I'm a Java developer so I just think of it that way. :)

          BTW, I am very happy about the opening of Yahoo's Javascript
          libraries. I look forward to the coming months when presumably more
          code is opened up to the public.

          Thanks again,

          Justin

          --- In ydn-javascript@yahoogroups.com, "Steven Peterson"
          <peterson@...> wrote:
          >
          > Justin,
          >
          >
          >
          > I tried getting your example to work, and at first I was baffled,
          but then I
          > caught a small typo. The constant that you want to use to prevent
          the render
          > stack from executing the default renderer is STOP_RENDER, rather than
          > STOP_RENDERER. Once I changed that, it worked without a problem.
          >
          >
          >
          > I noticed that you said that you couldn't get
          renderBodyCellRestricted to
          > work. Can you provide more details on the problem you had with it?
          If you
          > modify your init code as follows, it should work fine for you:
          >
          >
          >
          > function init() {
          >
          > cal1 = new
          > YAHOO.widget.Calendar("cal1","cal1Container");
          >
          > cal1.addRenderer("2/21/2006",
          > cal1.renderBodyCellRestricted);
          >
          > cal1.render();
          >
          > }
          >
          >
          >
          > Assuming you're pointing to the default CSS, it should render the
          date with
          > a strike-through. If you need any more assistance, don't hesitate to
          let me
          > know. :-)
          >
          >
          >
          > Thanks!
          >
          >
          >
          > Steven Peterson
          >
          > Web Developer, Platform Engineering
          >
          > Yahoo!
          >
          > _____
          >
          > From: ydn-javascript@yahoogroups.com
          [mailto:ydn-javascript@yahoogroups.com]
          > On Behalf Of Justin Ashworth
          > Sent: Tuesday, February 14, 2006 7:59 PM
          > To: ydn-javascript@yahoogroups.com
          > Subject: [ydn-javascript] Custom calendar renderers not working?
          >
          >
          >
          > I would like to create a calendar which does not allow selection on
          > certain holidays. I tried to use the
          > YAHOO.widget.Calendar.renderBodyCellRestricted renderer, but it did
          > not work. So then I tried to write a custom renderer which would just
          > place an "H" in the date of the holiday. Can somebody look at the
          > code below and see my mistake? Thank you so much!
          >
          > renderCellHoliday = function(workingDate, cell) {
          > cell.innerHTML = "";
          > cell.appendChild(document.createTextNode("H"));
          > return YAHOO.widget.Calendar_Core.STOP_RENDERER;
          > }
          >
          > function init() {
          > cal1 = new YAHOO.widget.Calendar("cal1","cal1Container");
          > cal1.addRenderer("2/21/2006", renderCellHoliday);
          > cal1.render();
          > }
          >
          > Thanks,
          >
          > Justin
          >
          >
          >
          >
          >
          >
          > SPONSORED LINKS
          >
          >
          > C
          >
          <http://groups.yahoo.com/gads?t=ms&k=C+programming+language&w1=C+programming
          >
          +language&w2=Computer+programming+languages&w3=Java+programming+language&w4=
          >
          The+c+programming+language&w5=C+++programming+language&w6=Concept+of+program
          > ming+language&c=6&s=194&.sig=lC1PxfzvANy_Br-nPkXYTA> programming
          language
          >
          > Computer
          >
          <http://groups.yahoo.com/gads?t=ms&k=Computer+programming+languages&w1=C+pro
          >
          gramming+language&w2=Computer+programming+languages&w3=Java+programming+lang
          >
          uage&w4=The+c+programming+language&w5=C+++programming+language&w6=Concept+of
          > +programming+language&c=6&s=194&.sig=7XFXh-0Mon1IfLuOVlwvdg>
          programming
          > languages
          >
          > Java
          >
          <http://groups.yahoo.com/gads?t=ms&k=Java+programming+language&w1=C+programm
          >
          ing+language&w2=Computer+programming+languages&w3=Java+programming+language&
          >
          w4=The+c+programming+language&w5=C+++programming+language&w6=Concept+of+prog
          > ramming+language&c=6&s=194&.sig=UITodqn0qTCUcae_mpRQog> programming
          > language
          >
          >
          > The
          >
          <http://groups.yahoo.com/gads?t=ms&k=The+c+programming+language&w1=C+program
          >
          ming+language&w2=Computer+programming+languages&w3=Java+programming+language
          >
          &w4=The+c+programming+language&w5=C+++programming+language&w6=Concept+of+pro
          > gramming+language&c=6&s=194&.sig=xnZC2-BzDSLhhir3MLtssg> c programming
          > language
          >
          > C
          >
          <http://groups.yahoo.com/gads?t=ms&k=C+++programming+language&w1=C+programmi
          >
          ng+language&w2=Computer+programming+languages&w3=Java+programming+language&w
          >
          4=The+c+programming+language&w5=C+++programming+language&w6=Concept+of+progr
          > amming+language&c=6&s=194&.sig=RTzTl3BOJWbWK14CdUrO0w> programming
          language
          >
          >
          > Concept
          >
          <http://groups.yahoo.com/gads?t=ms&k=Concept+of+programming+language&w1=C+pr
          >
          ogramming+language&w2=Computer+programming+languages&w3=Java+programming+lan
          >
          guage&w4=The+c+programming+language&w5=C+++programming+language&w6=Concept+o
          > f+programming+language&c=6&s=194&.sig=x4ueM0tA417JDq3ckdJ9CQ> of
          > programming language
          >
          >
          >
          > _____
          >
          > YAHOO! GROUPS LINKS
          >
          >
          >
          > * Visit your group "ydn-javascript
          > <http://groups.yahoo.com/group/ydn-javascript> " on the web.
          >
          > * To unsubscribe from this group, send an email to:
          > ydn-javascript-unsubscribe@yahoogroups.com
          > <mailto:ydn-javascript-unsubscribe@yahoogroups.com?subject=Unsubscribe>
          >
          > * Your use of Yahoo! Groups is subject to the Yahoo!
          > <http://docs.yahoo.com/info/terms/> Terms of Service.
          >
          >
          >
          > _____
          >
        • Philip Tellis
          ... In javascript, those would be global methods, or more correctly, methods of the default object. In the browser context, the default object is the window.
          Message 4 of 4 , Feb 15, 2006
          • 0 Attachment
            Sometime Today, JA cobbled together some glyphs to say:

            > my holiday example now works. The reason renderBodyCellRestricted
            > didn't work is because I was treating it as a static function
            > reference by using "YAHOO.widget.Calendar.renderBodyCellRestricted"
            > verbatim rather than "cal1.renderBodyCellRestricted". I don't even
            > know if there's such a thing as a static function reference in
            > Javascript - I'm a Java developer so I just think of it that way. :)

            In javascript, those would be global methods, or more correctly, methods
            of the default object. In the browser context, the default object is
            the window.

            --
            Nothing I do is my fault.
            -- Calvin
          Your message has been successfully submitted and would be delivered to recipients shortly.