Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
654
WebCalendarView Client Events
posted

Hello -

Unless I'm missing something, the client side events on the WebCalendarView seem to be lacking a large event - the DateClicked event.  This would be triggered when a user clicks a specific day.  Is this possible?  The WebCalendar has this event, so I'm not sure why WebCalendarView wouldn't implement the same?

I know that there's a click event, but I didn't see a way to tell if they clicked on a day.  I also know I could consume the server-side ActiveDayChanged event on the WebScheduleInfo, but this is triggered on a month change too.  I just want to be informed when a user explicitly selects a day...  Any thoughts?

Thanks!

Parents
  • 4960
    Verified Answer
    posted

    One solution would be to examine the [DOM] element which received the Clicked event, however this doesn't cover all cases in which the date may change (two examples: if keyboard navigation has been enabled then the date can also change via the arrow keys; or if the user selects a different month from the dropdown then the date can jump to a new month and/or year).

    Therefore, I'm going to mention the select function which is called at least once (potentially multiple times) when date changes occur. Instead of calling select to choose a different date, you can also (carefully) override this function to add custom pre- or post-processing in a daisy-chain manner.

    I add the following Javascript to a <script> block in my document's <head>,

    function WrapSelectFunction( )  {
        var oCalendarView1 = ig_getWebControlById("WebCalendarView1");
        if ( oCalendarView1 != null ) {
            oCalendarView1.select0 = oCalendarView1.select;
            oCalendarView1.select = function(year,month,day,i,e,post) {
                // notify your own client-side listeners before clicked or selected date changes - I am just writing to the status bar (IE only)
                window.status = "date selected = " + month.toString( ) + "/" + day.toString( ) + "/" + year.toString( );
                // call wrapped calendar view's original select function
               
    ig_getWebControlById("WebCalendarView1").select0(year,month,day,i,e,post);
            }
        }
    }

    and then I set the Init event of a WebCalendarView control on the page to call my piece of Javascript that replaces the WebCalendarView's normal select function with my own (while at the same time preserving the original function, so my overridden implementation can call it).

    <igsch:WebCalendarView ID="WebCalendarView1" runat="server" WebScheduleInfoID="WebScheduleInfo1">
       
    <ClientEvents Initialize="WrapSelectFunction" />
    </igsch:WebCalendarView>

    When using this technique, you always want to make sure you call the original WebSchedule client-side control's function, and you must exercise care with regard to things like re-entrancy or doing things that the control wouldn't expect.  Additionally, if active day synchronization is on, the select function can be triggered by a date change on another WebSchedule view control - I am unsure if this is something you would want to (or wouldn't want to) capture client-side.

Reply Children
No Data