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

Custom field mapping doesnt work

4 Answers 41 Views
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 05 Sep 2012, 02:16 PM
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

4 Answers, 1 is accepted

Sort by
0
Daniel
Top achievements
Rank 1
answered on 06 Sep 2012, 09:17 AM
SORRY guys,

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

Greetings

Danlei
0
Ivan Todorov
Telerik team
answered on 07 Sep 2012, 01:43 PM
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 >>
0
Jan Kristensen
Top achievements
Rank 1
answered on 25 Apr 2014, 12:47 PM
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
0
George
Telerik team
answered on 30 Apr 2014, 08:01 AM
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.
 
Asked by
Daniel
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 1
Ivan Todorov
Telerik team
Jan Kristensen
Top achievements
Rank 1
George
Telerik team
Share this question
or