5 Replies Latest reply: Apr 5, 2013 3:46 AM by kvlek RSS

    Apex 4.2: How refresh calendar region, a.k.a. javascript redirect to self

    emma-apex
      Hello

      I have a calendar that displays staff holidays.

      I have a pop-up LOV of staff names and want the calendar to display only the absences for the staff member selected.

      For now I have set the default value to 1 and included the :P65_STAFF_ID bind variable in my SQL.

      On loading, the page returns me only the absences for staff_ID = 1, which is correct. However when I change the staff name, the calendar data does not change.

      I've set up all the dynamic actions I can think of to refresh the calendar region or calendar items on the pop-up LOV changing, but no joy.

      My remaining idea is to use a dynamic action with javascript to redirect the page to itself on change. Is there a way to do this without writing out an entire URL, e.g. redirect(this.URL)?

      I am largely unfamiliar with JS. Also I figure it must be possible to refresh the calendar without a hack. Any help appreciated

      Thanks
      Emma
        • 1. Re: Apex 4.2: How refresh calendar region, a.k.a. javascript redirect to self
          VC
          emma-apex wrote:
          My remaining idea is to use a dynamic action with javascript to redirect the page to itself on change. Is there a way to do this without writing out an entire URL, e.g. redirect(this.URL)?
          in your dynamic action > set the true action as Execute Javascript Code
          With
          Code location.reload()
          • 2. Re: Apex 4.2: How refresh calendar region, a.k.a. javascript redirect to self
            emma-apex
            Thanks for the JS code. I couldn't get the thing to work with the LOV even with the JS. In the end I fixed it using a select list and setting option to 'Redirect and Set Value' which works a treat.
            • 3. Re: Apex 4.2: How refresh calendar region, a.k.a. javascript redirect to self
              kvlek
              Hi Emma,

              You could do it with an POP-UP LOV and Dynamic Action.

              Dynamic Action
              - Change
              - item P65_STAFF_ID
              True Actions
              1 - PL/SQL block;
                   - PL/SQL Code in this block you can get the last of first date for the absence of the STAFF_ID and put it in the date item for the calendar (eg P65_CALENDAR_DATE);
                   - Page Items to Submit P65_STAFF_ID
                   - Page Items to Return P65_CALENDAR_DATE
              2 - Execute Javascript Code
                   - apex.widget.calendar.ajax_calendar('M','same',$v('P65_CALENDAR_DATE'));

              This way the calendar will be refreshed and set to the date in P65_CALENDAR_DATE.

              You can also put "null;" in the PL/SQL block, leave the Page Items to Return empty and remove the ",$v('P65_CALENDAR_DATE')" part from the Javascript code. This way you do not open the calendar at the right date.

              I made a small example at http://apex.oracle.com/pls/apex/f?p=14257:4 (login as demo/demo).

              Regards,
              Kees Vlek
              -----
              <tt>Company: http://www.orcado.nl
              Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
              Twitter: http://www.twitter.com/skier66</tt>
              If the question is answered please change it to answered and mark the appropriate post as correct/helpfull.
              • 4. Re: Apex 4.2: How refresh calendar region, a.k.a. javascript redirect to self
                VC
                kvlek wrote:
                     - apex.widget.calendar.ajax_calendar('M','same',$v('P65_CALENDAR_DATE'));
                This way the calendar will be refreshed and set to the date in P65_CALENDAR_DATE.
                And hard-coding the calendar view to monthly ignoring the current view you are in. It always shows the monthly view!
                • 5. Re: Apex 4.2: How refresh calendar region, a.k.a. javascript redirect to self
                  kvlek
                  >
                  VC wrote:
                  And hard-coding the calendar view to monthly ignoring the current view you are in. It always shows the monthly view!
                  >
                  You are totaly right, it was a quick example.
                  Off course you can use the hidden item for the calendar type in the call to preserve the current view.
                  apex.widget.calendar.ajax_calendar($v('P65_CALENDAR_TYPE'),'same',$v('P65_CALENDAR_DATE'));
                  or even better use 'S' (short for same? ;-))
                  apex.widget.calendar.ajax_calendar('S','same',$v('P65_CALENDAR_DATE'));
                  Kees

                  Edited by: kvlek on 5-apr-2013 10:45