This is a migrated thread and some comments may be shown as answers.

EnableMultiSelect = False but UseColumnHeadersAsSelectors = True ?

4 Answers 79 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Sébastien
Top achievements
Rank 2
Sébastien asked on 07 Jul 2009, 09:15 AM
Hello Telerik Team !

I would like, throught RadCalendar, to give the ability to use the Column and Row headers as multi-selectors, but not give the ability to multi-select single days. As it, the user can select all the Mondays for example, or the whole 15th week of the year, but not the 5 march and 15 june and 6 april 2010, etc. (the user can select the 5 march individually, but not cumulated with another single day) Also, I would like that the pseudo-multi-selection that happens when a row or column header is clicked, could'nt be cumulated with a previous selection, creating a postBack.
Any ideas ?

Here is my code :
<telerik:radcalendar id="radCalSearch" runat="server"   
            enablemultiselect="false"   
            showrowheaders="true"   
            UseColumnHeadersAsSelectors="true"   
            UseRowHeadersAsSelectors="true" 
            enablenavigationanimation="false" 
            fastnavigationnextimage="~/images/btn_RadCal_FN.jpg" 
            fastnavigationprevimage="~/images/btn_RadCal_FP.jpg" 
            navigationnextimage="~/images/btn_RadCal_N.jpg" 
            navigationprevimage="~/images/btn_RadCal_P.jpg" 
            daynameformat="FirstTwoLetters" 
            onselectionchanged="radCalSearch_SelectionChanged" AutoPostBack="true">  
        <SpecialDays> 
            <telerik:RadCalendarDay Date="" Repeatable="Today">  
                <ItemStyle CssClass="radCalToday_Default" /> 
            </telerik:RadCalendarDay> 
        </SpecialDays> 
    </telerik:radcalendar> 

 Protected Sub radCalSearch_SelectionChanged(ByVal sender As ObjectByVal e As Telerik.Web.UI.Calendar.SelectedDatesEventArgs) Handles radCalSearch.SelectionChanged  
            Try 
                SetSession(TrueFalse)  
                If intSearchTabID <> -1 Then 
                    Response.Redirect(NavigateURL(intSearchTabID, False))  
                End If 
            Catch exc As Exception    'Module failed to load  
                ProcessModuleLoadException(Me, exc)  
            End Try 
        End Sub 

Sébastien

4 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 09 Jul 2009, 02:19 PM
Hello Fichot,

Ti disable individual date selection but enable multi date selection, simply cancel the date OnDateClick event in RadCalendar's client events:

function dateClick(sender, args) { 
    args.set_cancel(true); 

I am not sure I understand your second question, though. Could you, please clarify.

Best wishes,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Sébastien
Top achievements
Rank 2
answered on 09 Jul 2009, 03:02 PM
Hi, and thanks you for this answer, but I guess it will not work, as I want to be able to select a day by clicking on his calendar reference, but not multiselect days other than with the use of the headers/columns buttons.

The second part of the question isn't so clear you're right.
To be short, I would like to be able to multi-select days with the week select buttons, but not multi-select weeks, or multi-select days without using the week select buttons.
But again, it may not be clear, so let's follow this set of user-stories :
- The user can select all the days of the week by clicking on the number of the week. This creates a PostBack and displays the result.
- The user can select all the Sundays by clicking on the Sunday header. This creates a PostBack and displays the result.
- The user can select a single date. This creates a PostBack and displays the result.
- The user can't cumulate two single selected dates.
- The user can't select two weeks.
- The user can't select the Sundays and the Thursdays.


Cheers,

S.F.
0
Veli
Telerik team
answered on 10 Jul 2009, 09:29 AM
Hi Fichot,

On the first question, you need to modify a little bit your client-side OnDateClick event handler:

function dateClick(sender, args)  
{  
    while(sender.get_selectedDates().length > 0) 
    { 
        sender.unselectDate(sender.get_selectedDates()[0]); 
    } 
}  


The above code will deselect any previously selected dates when you click on a date. Effectively, only the last clicked date will get selected, and the previously licked do not. At the same time, row and column selection will work untouched.

As for the second question, the above code can be used also when clicking the row header, to deselect any previously selected rows of dates. Additionally, to disable certain week days, you can use the OnColumnHeaderClick event, where the second argument's get_index() accessors returns the 1-based index of week days starting from the first day of week.

Here is the ClientEvents markup in RadCalendar:

<ClientEvents OnDateClick="clearPreviousSelectedDates"  
    OnRowHeaderClick="clearPreviousSelectedDates" 
    OnColumnHeaderClick="disableColumnHeader"/> 

And here is the additional disableColumnHeader() method handler:

function disableColumnHeader(sender, args) 
    //My week start day is Sunday, so it has index 1  
    //and Thursday has index 5 
    if(args.get_index() == 1 || args.get_index() == 5) 
    { 
        args.set_cancel(true); 
    } 

Regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Adek
Top achievements
Rank 1
answered on 13 Jul 2009, 10:33 AM

where is function clearPreviousSelectedDates ??

edit:

ok I have :D

sender.unselectDates(sender.get_selectedDates());

Tags
Calendar
Asked by
Sébastien
Top achievements
Rank 2
Answers by
Veli
Telerik team
Sébastien
Top achievements
Rank 2
Adek
Top achievements
Rank 1
Share this question
or