This is a migrated thread and some comments may be shown as answers.
Select week or single day, but not multiple days
5 Answers 63 Views
This is a migrated thread and some comments may be shown as answers.
Gavin Pollock
Top achievements
Rank 1
Gavin Pollock asked on 12 May 2010, 07:59 AM
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

5 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 12 May 2010, 09:07 AM

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.

0
Gavin Pollock
Top achievements
Rank 1
answered on 12 May 2010, 09:16 AM
perfect, amazingly helpful as always... thanks!

Had to also turn off column selection in conjunction, otherwise everything as wanted.
0
Shinu
Top achievements
Rank 1
answered on 17 May 2010, 01:33 PM

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.

0
@CC
Top achievements
Rank 1
answered on 04 Nov 2010, 05:07 PM
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!
0
Tsvetina
Telerik team
answered on 10 Nov 2010, 09:01 AM
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
Asked by
Gavin Pollock
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Gavin Pollock
Top achievements
Rank 1
@CC
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or