How to implement the date selection range event after the user has finished the selection?

4 posts, 0 answers
  1. Edielton
    Edielton avatar
    2 posts
    Member since:
    Oct 2011

    Posted 26 Oct 2011 Link to this post

    Hello telerik team!


    We implemented the RadCalendar control in our application and we are stuck in an issue regarding the calendar range selection. We want the user to select the range of dates and once he selected the range we needed to trigger an event to process the information within that range. The problem is that none of the events from the contorols list seems to achieve this goal. We tried to implement the SelectionChanged, but even before the user finished selecting the range the event fired...

    Which event would you suggest us to use? Could you provide an example?

    Best regards,
    Edielton
    SistemaPri
  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 31 Oct 2011 Link to this post

    Hello Edielton,

    When using Extended SelectionMode you can select dates either by dragging, using Shift or Control keys. There is no way for us to know when the selection is finished as you can always add another date with Control or Shift, so that is why there is no event that suits your needs. You have two choices.

    1. Use the KeyDown event and check for a specific key press(Enter for example) that will confirm the selection and in this event you will handle the selected dates.

    2. Change the way your application works so it can use the SelectionChanged event and its parameters like AddedItems and RemovedItems.

    Hope this helps. Let us know if you have further questions.

    Best wishes,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Edielton
    Edielton avatar
    2 posts
    Member since:
    Oct 2011

    Posted 31 Oct 2011 Link to this post

    Hello Boyan, thanks for your reply!

     

    From the solutions you suggested, the one who would fit to our needs would be the KeyDown event. The problem with the second solution is that we don't know when the selection changed, something you informed in the response below, what would make countless calls to our async service for every date selected. The KeyDown event is a good candidate, but we figured out that it just works when we click off the object's 'surface'. If you guys make it fire the event once the KeyDown is pressed over the date, that would be the way to go.

    Any possibilities for that?

    Once again, thanks for your comprehension.

    Edielton
    SistemaPri

     



  5. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 03 Nov 2011 Link to this post

    Hello Edielton,

    I am not sure that I understand what you are trying to achieve. What do you mean by "click off the object's surface " ? The solution that I had in mind is
    private void calendar1_KeyUp(object sender, KeyEventArgs e)
            {
                if (e.Key == Key.Enter)
                {
                    var a = calendar1.SelectedDates;
                    //do sth with SelectedDates  collection
                }
            }
    So the sequence is the following, select dates in the RadCalendar either by dragging or using CTRL or Shift button, then press Enter to confirm the selection. The event of course will be invoked only if the control is on focus when the Enter key is pressed.


    Kind regards,
    Boyan
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top