RadCalendar selection problem(urgent!)

4 posts, 0 answers
  1. Ahmet Ozkan
    Ahmet Ozkan avatar
    4 posts
    Member since:
    Dec 2009

    Posted 04 Dec 2009 Link to this post

    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?
  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 04 Dec 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tim
    Tim avatar
    9 posts
    Member since:
    Jul 2011

    Posted 18 Apr 2013 Link to this post

    How do we do this for the Silverlight RadCalendar
  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 24 Apr 2013 Link to this post

    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.

Back to Top