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

How to disable date deselect?

4 Answers 127 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
wajira
Top achievements
Rank 1
wajira asked on 26 Oct 2009, 01:25 PM
I'm using RAD Calender with Multiselect = 'False'.
When I click on an already selected date, the date get deselected.
I want to stop that.

Is there any property to do that or How Can I do that?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Oct 2009, 04:59 AM
Hi,

Attach OnDateSelecting event to RadCalendar and try the following client side code.

js:
 
<script type="text/javascript"
    function OnDateSelecting(sender, args) {   
        if (args._renderDay.IsSelected) { 
            args.set_cancel(true); 
        } 
    } 
</script> 

-Shinu.
0
wajira
Top achievements
Rank 1
answered on 27 Oct 2009, 06:28 AM
Hi Shinu ,

It looks It works.
Thanx.
0
Samuel
Top achievements
Rank 1
answered on 07 Feb 2011, 09:24 PM
Does this solution still work?
When I try this script, it breaks the EnableMultiSelect="False"
In other words, multiple days can be selected despite multiselect being turned off.

I am using 2010.03.1109.40
0
Marin
Telerik team
answered on 10 Feb 2011, 05:08 PM
Hi Samuel,

You can use the OnDateClick event to get the date that is about to be selected and then compare it with the current date. Here is a code sample:

var date = null;
        function OnDateSelecting(sender, args) {  
            var currentDate = args.get_renderDay().get_date();
            var newDate = new Date(currentDate[0], currentDate[1], currentDate[2]);
            if (args.get_renderDay().IsSelected && isDatesEquals(date,newDate)) {
                args.set_cancel(true);
            }
        };
 
        function OnDateClick(sender, eventArgs)
        {
            var d = eventArgs.get_renderDay().get_date();
            date = new Date(d[0], d[1], d[2]);
        }
 
        function isDatesEquals(date1, date2)
        {
            if(date1.getFullYear() == date2.getFullYear() && date1.getMonth() == date2.getMonth() && date1.getDate() == date2.getDate())
            {
                return true;
            }
            else return false;
        }

Best wishes,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Calendar
Asked by
wajira
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
wajira
Top achievements
Rank 1
Samuel
Top achievements
Rank 1
Marin
Telerik team
Share this question
or