I am using the Resource dropdownlist for my resouces (room/booth/oven selection). How do I remove "ANY" from Resource dropdownlist in the Dialog box? I want to allow the user to be able to select only one resource. Please refer to my attachment.
Best regards,
Dominic
1 Answer, 1 is accepted
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Nov 2021, 11:02 AM
Hello, Dominic,
Please have in mind that as of R1 2021 the EditAppointmentDialog provides UI for selecting multiple resources per appointment. In certain cases (e.g. unbound mode), the Resource RadDropDownList is replaced with a RadCheckedDropDownList.
Otherwise, the default drop down with single selection for resources is shown. To enable the multiple resources selection in bound mode, it is necessary to specify the AppointmentMappingInfo.Resources property. The Resources property should be set to the name of the relation that connects the Appointments and the AppointmentsResources tables.
You can create a derivative of the EditAppointmentDialog class and override its LoadResources method. The cmbResource is the default RadDropDownList, the checkedCmbResource control is RadCheckedDropDownList used for the newly introduced functionality. The Items collection in both controls stores the resource items. You can remove of the items that are redundant in your case. The edit dialog offers the CanHaveMultipleResources method which also allows you to control which of the two resources lists will be displayed considering the returned boolean result.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik
Hi Dess, can you show me an example of setting the "CanHaveMultipleResources" method in VB ? Thanks.
Dess | Tech Support Engineer, Principal
Telerik team
commented on 05 Nov 2021, 09:28 AM
Hi, Dominic,
I have prepared a sample code snippet demonstrating how to create a custom edit dialog and override its CanHaveMultipleResources method. Then, this dialog can replace the default one in the AppointmentEditDialogShowing event:
SubNew()
InitializeComponent()
Dim colors() As Color = {Color.LightBlue, Color.LightGreen, Color.LightYellow, Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue}
Dim names() AsString = {"Alan Smith", "Anne Dodsworth", "Boyan Mastoni", "Richard Duncan", "Maria Shnaider"}
For i AsInteger = 0To names.Length - 1Dim resource AsNew Telerik.WinControls.UI.Resource()
resource.Id = New EventId(i)
resource.Name = names(i)
resource.Color = colors(i)
Me.RadScheduler1.Resources.Add(resource)
Next i
Me.RadScheduler1.GroupType = GroupType.Resource
AddHandlerMe.RadScheduler1.AppointmentEditDialogShowing, AddressOf RadScheduler_AppointmentEditDialogShowing
EndSubDim dialog As CustomEditAppointmentDialog
PrivateSub RadScheduler_AppointmentEditDialogShowing(sender AsObject, e As AppointmentEditDialogShowingEventArgs)
If dialog IsNothingThen
dialog = New CustomEditAppointmentDialog
EndIf
e.AppointmentEditDialog = dialog
EndSub
However, it is important to note that this is a valid code in case you are using at least R1 2021 or newer. Otherwise, the CanHaveMultipleResources method wouldn't be available. In this case, you need to hide the Any item by using the following custom implementation in the edit dialog: