Select week or single day, but not multiple days

6 posts, 1 answers
  1. Gavin Pollock
    Gavin Pollock  avatar
    62 posts
    Member since:
    Jan 2005

    Posted 12 May 2010 Link to this post

    Hi there,

    I'm trying to have the Calendar work in a scenario that is essentially the same as EnableMultiSelect=false  but also allow the user to select an entire week. What I don't want is the user to have the multiple select turned on where if they are clicking single days it will add them to the selection.

    On single day clicks I want the calendar to lose the current selection, and select the day they just clicked.
    On week click I want the whole week selected.

    Can see that this is similar, but not quite sure which client events I can modify to make it work like this?
    http://www.telerik.com/community/code-library/aspnet-ajax/calendar/calendar-week-selection-only-with-confirmation-popup.aspx

    Any help would be appreciated!

    Cheers
    Gavin
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 May 2010 Link to this post

    Hello Gavin,

    Try the following approach and see whether it meet your requirement.

    ASPX:

     
    <telerik:RadCalendar ID="RadCalendar2" runat="server" Skin="Outlook">  
        <ClientEvents OnRowHeaderClick="OnRowHeaderClick" OnDateClick="OnDateClick" OnDateSelecting="OnDateSelecting" />  
    </telerik:RadCalendar> 

    JavaScript:

     
    <script type="text/javascript">  
        var check = true;  
        var weekClick = true;  
        function OnDateSelecting(sender, args) {  
            if (!check && !weekClick) {  
                if (sender.get_selectedDates().length > 0) {  
                    check = true;  
                    sender.unselectDates(sender.get_selectedDates());                 
                }  
            }  
            check = false;  
        }  
        function OnDateClick(sender, args) {  
            weekClick = false;  
        }  
        function OnRowHeaderClick(sender, args) {  
            check = true;  
            weekClick = true;  
            sender.unselectDates(sender.get_selectedDates());  
        }  
    </script> 

    -Shinu.

  3. Gavin Pollock
    Gavin Pollock  avatar
    62 posts
    Member since:
    Jan 2005

    Posted 12 May 2010 Link to this post

    perfect, amazingly helpful as always... thanks!

    Had to also turn off column selection in conjunction, otherwise everything as wanted.
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 May 2010 Link to this post

    Hello Gavin,

    You can cancel the 'OnColumnHeaderClick' event by using args.set_cancel(true) method.

    JavaScript:

     
        function OnColumnHeaderClick(sender, args) {  
            args.set_cancel(true);  
        } 

    Cheers,

    Shinu.

  5. @CC
    @CC avatar
    6 posts
    Member since:
    Jun 2008

    Posted 04 Nov 2010 Link to this post

    Hello:

    Thank you for the sample! I was wondering if it was feasible to change the "week no column" to a more descriptive text say "week #" or "week 40" as opposed to just "40". Any insight is greatly appreciated.

    Thanks!
  6. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 10 Nov 2010 Link to this post

    Hi,

    RadCalendar does not provide the described functionality out-of-the box. Anyway, you can set a RowHeaderText or RowHeaderImage which will appear instead of the week numbers but will be one and the same for all row headers.

    For more information see this help article.

    Greetings,
    Tsvetina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top