Custom field mapping doesnt work

5 posts, 0 answers
  1. Daniel
    Daniel avatar
    7 posts
    Member since:
    Feb 2012

    Posted 05 Sep 2012 Link to this post

    Hi,

    I was trying to add a custom field to the EditAppointment dialog of  my scheduler. The field is a combobox and I can select a value, but the mapping doesn't work, its always null. Here are some code snippets:

    MainForm:
    Public Sub New()
        InitializeComponent()
      
        AddHandler Me.RadScheduler.AppointmentEditDialogShowing, AddressOf RadScheduler_AppointmentEditDialogShowing
      
        Me.RadScheduler.AppointmentFactory = New AppointmentWithNewFieldsFactory
        Me.SchedulerBindingDataSource1.EventProvider.AppointmentFactory = New AppointmentWithNewFieldsFactory
      
        Dim appointmentMappingInfo As AppointmentMappingInfo = TryCast(Me.SchedulerBindingDataSource1.EventProvider.Mapping, AppointmentMappingInfo)
        appointmentMappingInfo.Mappings.Add(New SchedulerMapping("CustomField", "CustomFieldDatabase"))
    End Sub
     
        Private appointmentDialog As IEditAppointmentDialog = Nothing
        Private Sub RadScheduler_AppointmentEditDialogShowing(sender As Object, e As AppointmentEditDialogShowingEventArgs) Handles RadScheduler.AppointmentEditDialogShowing
            If Me.appointmentDialog Is Nothing Then
                Me.appointmentDialog = New AppointmentWithNewFieldsEditForm()
            End If
            e.AppointmentEditDialog = Me.appointmentDialog
        End Sub

    AppointmentWithNewFields Class:
    Imports Telerik.WinControls.UI
     
    Public Class AppointmentWithNewFields
        Inherits Appointment
     
        Public Sub New()
            MyBase.New()
        End Sub
     
        Private _CustomField As Integer
     
        Public Property CustomField() As Integer
            Get
                Return Me._CustomField
            End Get
            Set(value As Integer)
                If Me._CustomField <> value Then
                    Me._CustomField = value
                    Me.OnPropertyChanged("CustomField")
                End If
            End Set
        End Property

    AppointmentWithNewFieldsEditForm
    Imports Telerik.WinControls.UI
     
    Public Class AppointmentWithNewFieldsEditForm
        Inherits Telerik.WinControls.UI.Scheduler.Dialogs.EditAppointmentDialog
     
        Public Sub New()
            InitializeComponent()
        End Sub
     
        Protected Overrides Sub LoadSettingsFromEvent(ByVal ev As IEvent)
            MyBase.LoadSettingsFromEvent(ev)
     
            Dim appointmentWithNewFields As AppointmentWithNewFields = TryCast(ev, AppointmentWithNewFields)
            If appointmentWithNewFields IsNot Nothing Then
                Me.ComboBoxCustomField.SelectedValue = appointmentWithNewFields.CustomField
            End If
        End Sub
     
        Protected Overrides Sub ApplySettingsToEvent(ByVal ev As IEvent)
            Dim appointmentWithNewFields As AppointmentWithNewFields = TryCast(ev, AppointmentWithNewFields)
            If appointmentWithNewFields IsNot Nothing Then
                appointmentWithNewFields.CustomField= Me.ComboBoxCustomField.SelectedValue
            End If
            MyBase.ApplySettingsToEvent(ev)
        End Sub
     
        Protected Overrides Function CreateNewEvent() As IEvent
            Return New AppointmentWithNewFields()
        End Function

    AppointmentsWithNewFieldsFactory:
    Imports Telerik.WinControls.UI
     
    Public Class AppointmentWithNewFieldsFactory
        Implements IAppointmentFactory
    #Region "IAppointmentFactory Members"
        Public Function CreateNewAppointment() As IEvent Implements IAppointmentFactory.CreateNewAppointment
            Return New AppointmentWithNewFields()
        End Function
    #End Region
    End Class

    What did I wrong? Can anyone help me please?

    Thanks + greetings

    Daniel
  2. Daniel
    Daniel avatar
    7 posts
    Member since:
    Feb 2012

    Posted 06 Sep 2012 Link to this post

    SORRY guys,

    i made a mistake in my database. Now, everything works fine :-).

    Greetings

    Danlei
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 07 Sep 2012 Link to this post

    Hello Daniel,

    I am glad to hear that you have managed to sort this out.

    In case you have any further questions, do not hesitate to contact us.

    All the best,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  5. Jan Kristensen
    Jan Kristensen avatar
    2 posts
    Member since:
    May 2011

    Posted 25 Apr 2014 in reply to Daniel Link to this post

    Hej Daniel

    I having the same problem as original describe in your post.

    You wrote you have made a mistake in the database. What was the mistake, perhaps I have done the same.

    Regards
    Jan
  6. George
    Admin
    George avatar
    500 posts

    Posted 30 Apr 2014 Link to this post

    Hello Jan,

    Thank you for replying.

    I am not sure what mistake Daniel made, but if you open a new support ticket and provide us with more details about your setup and possibly with a sample project we will provide you with adequate support.

    I am looking forward to hearing from you again.

    Regards,
    George
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WinForms is Visual Studio 2017 Ready