VB: How do I remove "ANY" from Resource dropdownlist in the Dialog box?

1 Answer 61 Views
Scheduler and Reminder
Dominic
Top achievements
Rank 2
Iron
Iron
Iron
Dominic asked on 03 Nov 2021, 04:18 AM

Hi,

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

Sort by
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.

scheduler-winforms-scheduler-dialogs-editappointmentdialog 003

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

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Dominic
Top achievements
Rank 2
Iron
Iron
Iron
commented on 05 Nov 2021, 07:05 AM

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:

Public Class CustomEditAppointmentDialog
    Inherits EditAppointmentDialog
    Protected Overrides Function CanHaveMultipleResources() As Boolean
        Dim defaultValue As Boolean = MyBase.CanHaveMultipleResources()
        Return defaultValue
    End Function
End Class
    Sub New()
        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() As String = {"Alan Smith", "Anne Dodsworth", "Boyan Mastoni", "Richard Duncan", "Maria Shnaider"}
        For i As Integer = 0 To names.Length - 1
            Dim resource As New 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

        AddHandler Me.RadScheduler1.AppointmentEditDialogShowing, AddressOf RadScheduler_AppointmentEditDialogShowing
    End Sub

    Dim dialog As CustomEditAppointmentDialog
    Private Sub RadScheduler_AppointmentEditDialogShowing(sender As Object, e As AppointmentEditDialogShowingEventArgs)
        If dialog Is Nothing Then
            dialog = New CustomEditAppointmentDialog
        End If
        e.AppointmentEditDialog = dialog

    End Sub

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: 

Public Class CustomEditAppointmentDialog
    Inherits EditAppointmentDialog

    Protected Overrides Sub LoadResources()
        MyBase.LoadResources()
        Me.cmbResource.Items.RemoveAt(0)
    End Sub
End Class

Dominic
Top achievements
Rank 2
Iron
Iron
Iron
commented on 06 Nov 2021, 02:45 AM

Hi Dess, yes it works now. I think my version is before R1 2021. Thanks for your example and quick response.
Tags
Scheduler and Reminder
Asked by
Dominic
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or