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

RadCalendar selection problem(urgent!)

3 Answers 103 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Ahmet Ozkan
Top achievements
Rank 1
Ahmet Ozkan asked on 04 Dec 2009, 03:48 PM
Hi everybody,
    Firstly I used version of Telerik Q1 and I have trouble with radcalendar, problem is this:

    I provide dates for the calendar when page is loading, and calendar's allow multiple date selection. After page load I see the selected dates well. I want to achive that, when I click a date, post clicked date to another page via request. However when I clicked one of formerly selected date this date is disselect, and it gives me the previous selected date, for example when i click
"november 3" it gives me nothing than i clicked "4 november" it gives me "3 november" and that's going like that. My question is that actually; How can I prevent disselection when i clicked a formerly selected date?

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 04 Dec 2009, 04:30 PM
Hi Ahmet,

You can prevent deselection by using the OnDateSelecting client event:

http://www.telerik.com/help/aspnet-ajax/calendar_clientsideondateselecting.html

<telerik:RadCalendar ID="RadCalendar1" runat="server" EnableMultiSelect="true">
    <ClientEvents OnDateSelecting="MyDateSelecting" />
</telerik:RadCalendar>

<script type="text/javascript">

function MyDateSelecting(sender, args)
{
    if (!args.get_isSelecting())
        args.set_cancel(true);
}

</script>



Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Tim
Top achievements
Rank 1
answered on 18 Apr 2013, 10:24 PM
How do we do this for the Silverlight RadCalendar
0
Vladi
Telerik team
answered on 24 Apr 2013, 08:57 AM
Hi,

In order to achieve the desired behavior in Silverlight you could use the SelectionChanged event of the RadCalendar control and in that event use the SelectionChangedEventArgs to get the RemovedItems collection and add it to the SelectedDates of the control.

Th next code snippet represents the described approach:
in the xaml:
<telerik:RadCalendar SelectionChanged="RadCalendar_SelectionChanged_1"
            SelectionMode="Multiple"/>

and in the code behind:
private void RadCalendar_SelectionChanged_1(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
    var calendar = sender as RadCalendar;
    var removedItems = e.RemovedItems as IList<object>;
 
    Dispatcher.BeginInvoke(() =>
    {
        foreach (var item in removedItems)
        {
            if (!calendar.SelectedDates.Contains((DateTime)item))
            {
                calendar.SelectedDates.Add((DateTime)item);
            }
        }
    });
}

You should note that the Dispatcher is required as the selection needs to be slowed in order for the adding functionality to work. Hope this is helpful.

I would kindly ask you if you have any other or future Silverlight questions to post them in the Silverlight forum section.

Greetings,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Calendar
Asked by
Ahmet Ozkan
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Tim
Top achievements
Rank 1
Vladi
Telerik team
Share this question
or