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

Select multiple days with CTRL key?

13 Answers 135 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 10 Oct 2016, 09:23 AM

Is it possible to select multiple days with CTRL key? I know it is possible to select multiple appointments this way, but not the days.
It is currently also possible to select a day range with the SHIFT key but not individual days with CTRL key.

13 Answers, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 11 Oct 2016, 07:02 AM
Hello Ivo,

You could modify the default slot selection behavior - by implementing a custom one as shown below:
http://docs.telerik.com/devtools/silverlight/controls/radscheduleview/features/slot-selection-behavior

However if you need to achieve something else, I would ask you to share some more details regarding the exact scenario you need to achieve as well as the ViewDefinition you are using.

I'm looking forward to hearing from you.

Regards,
Kalin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Tim
Top achievements
Rank 1
answered on 11 Oct 2016, 07:15 AM

Hi Kalin,

I need to select individual slots using CTRL key like you can select files in the File Explorer in Windows. For example I need to select in January 5th, 9th and 10th day/slot. A user would hold CTRL key and click on those individual slots. Currently CTRL behaves like SHIFT key, it selects the date range. Can I do that with SlotSelectionBehavior while leaving SHIFT behaviour key as it is?

0
Kalin
Telerik team
answered on 12 Oct 2016, 08:48 AM
Hello Ivo,

You should be able to achieve the desired, by overriding the GetSelectionOverride method and checking if the control key is pressed. Check the following code snippet:

public class CustomSlotSelectionBehavior : SlotSelectionBehavior
{
    protected override Slot GetSelectionOverride(SlotSelectionState state, Slot currentSlot)
    {
        if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
        {
            // Implement custom logic that selects the needed slots.
            return currentSlot;
        }
        else
        {
            return base.GetSelectionOverride(state, currentSlot);
        }
    }
}

Hope this will help you.

Regards,
Kalin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Tim
Top achievements
Rank 1
answered on 14 Oct 2016, 01:57 PM

Hi Kalin,

I tried with you example but it is not functioning like I would I like to.
The currentSlot which is passed and also returned holds the range which is not what I want. I can't return collection of days. Here Slot class means a range (a little bit misleading name maybe). What I would like is to select individual days and it seems I can't do it. Is there another solution?

0
Kalin
Telerik team
answered on 17 Oct 2016, 10:25 AM
Hi Ivo,

Indeed only single Slot can be selected at a time. However what you can do would be to return a single slot with recurrence pattern that matches the desired result. In order to implement this you could use the MouseOverSlot of RadScheduleView in order to get the currently clicked slot and use it for the logic that generates the pattern. Please check the following sample implementation of custom SlotSelectionBehavior (note that it might not work as expected in every scenario - you should improve depending on requirements):

public class CustomSlotSelectionBehavior : SlotSelectionBehavior
{
    private RadScheduleView scheduleView;
    private List<Slot> clickedSlots;
 
    public CustomSlotSelectionBehavior(RadScheduleView scheduleView)
    {
        this.scheduleView = scheduleView;
        this.clickedSlots = new List<Slot>();
    }
 
    protected override Slot GetSelectionOverride(SlotSelectionState state, Slot currentSlot)
    {
        if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
        {
            var slotToRemove = this.clickedSlots.FirstOrDefault(s=> s.Start.Day == this.scheduleView.MouseOverSlot.Start.Day);
            if (slotToRemove != null)
            {
                this.clickedSlots.Remove(slotToRemove);
            }
            else
            {
                this.clickedSlots.Add(this.scheduleView.MouseOverSlot);
            }
 
            var pattern = new RecurrencePattern();
            pattern.Frequency = RecurrenceFrequency.Monthly;
            var daysOfMonth = new List<int>();
            foreach (var slot in this.clickedSlots)
            {
                daysOfMonth.Add(slot.Start.Day);
            }
 
            pattern.DaysOfMonth = daysOfMonth.ToArray();
            pattern.MaxOccurrences = daysOfMonth.Count;
            var result = new Slot(currentSlot.Start.Date, currentSlot.Start.Date.AddDays(1));
            result.RecurrencePattern = pattern;
            return result;
        }
        else
        {
            this.clickedSlots.Clear();
            return base.GetSelectionOverride(state, currentSlot);
        }
    }
}

And behavior should be assigned in the code behind in order to pass the ScheduleView instance as shown below:
this.scheduleView.SlotSelectionBehavior = new CustomSlotSelectionBehavior(this.scheduleView);

Hope this will help you to achieve the desired.

Regards,
Kalin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Tim
Top achievements
Rank 1
answered on 24 Oct 2016, 09:40 AM

Hi Kalin,

I tried you solution with some changes. It works well but only for one month period because the recurrent pattern parameter DaysOfMonth can only have one month's days (from 1 -31).
Is it possible to return the slot with days which are in different months?

0
Kalin
Telerik team
answered on 26 Oct 2016, 12:30 PM
Hello Ivo,

I tested the explained scenario and was able to select days from different months without a problem. However if needed you could implement a different recurrence pattern - for more details check the following article:
http://docs.telerik.com/devtools/silverlight/controls/radscheduleview/features/recurrence/recurrences-recurrencepattern

Hope this helps.

Regards,
Kalin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Tim
Top achievements
Rank 1
answered on 26 Oct 2016, 02:49 PM

Hi Kalin,

Yes, that looks like it works if you select different day number in both months. When you try selecting at the same time let's say November 1. and December 1. this is not possible as there is no way to pass the dates but only the day numbers, thus 2 of the same day numbers from different months will not work.

I took a look at the Yearly recurrence pattern but it still doesn't allow selecting specific dates. Or I'm missing something?

0
Kalin
Telerik team
answered on 28 Oct 2016, 08:38 AM
Hi Ivo,

Two equal day numbers (1st Nov & 1st Dec) could be selected at same time without a problem. If you are using MonthViewDefinition you could modify the code to remove only slot whenever the same slot is present in the collection as shown below:
var slotToRemove = this.clickedSlots.FirstOrDefault(s => s == this.scheduleView.MouseOverSlot);

This would allow you to firstly click on 1st Nov and then on 1st Dec and will work alright. However you won't be able to select days from November and then click on the 1st Dec (this will select 1st Nov). I'm afraid that the other recurrence patterns won't be useful this scenario.

However can explain the exact scenario you want to support? Note that this is just a workaround to achieve a not supported scenario and might not work as expected in all cases. So you might need to allow only selection of days of the current month for example.

If you have any other questions - please let us know.

Regards,
Kalin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Tim
Top achievements
Rank 1
answered on 28 Oct 2016, 08:48 AM

Yes. I've reached the same conclusion. With this solution you can only select one month period while holding CTRL key.

The scenario I would like to have is for the user to have a view of a period of time. It can be 2 months or more, it doesn't matter, whichever allows you to comfortable select individual slots. Then the user click a button and books an appointment for all the selected days. The requirement is to select it with the CTRL button but it can be any other user friendly way if it is possible.

0
Kalin
Telerik team
answered on 31 Oct 2016, 08:03 AM
Hello Ivo,

This is the best solution we could suggest in order to achieve such a scenario. You could play around with the recurrence patterns to see if a better behavior can be implemented.

If you have any other questions or concerns, please let us know.

Regards,
Kalin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Tim
Top achievements
Rank 1
answered on 09 Nov 2016, 07:40 AM

Hi Kalin

Is it possible to add this functionality in a future release?

0
Kalin
Telerik team
answered on 11 Nov 2016, 08:31 AM
Hi Ivo,

We don't have plans for implementing such a functionality in the future releases. However what I can suggest you would be check our Feedback portal where you can log that as a feature request, describing the exact scenario and requirements you need to achieve using such a feature.

Regards,
Kalin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
ScheduleView
Asked by
Tim
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Tim
Top achievements
Rank 1
Share this question
or