Completed
Last Updated: 14 Oct 2014 06:11 by ADMIN
ADMIN
George
Created on: 17 Mar 2014 14:05
Category: GanttView
Type: Bug Report
0
FIX. RadGanttView - Binding to a double property causes GanttViewSpinEditor to throw exception.
To reproduce:

Bind to an object with a property of type double. Start the application and edit that same column. End the editing process and you will see an exception that decimal cannot be converted to double.

Workaround:

Create the following custom editor:

public class MySpinEditor : GanttViewSpinEditor
{
    public override object Value
    {
        get
        {
            object value = base.Value;
            return Convert.ChangeType(value, this.ValueType);
        }
        set
        {
            base.Value = value;
        }
    }
}

Subscribe to the EditorInitialized and EditorRequired events and use the following event handlers:

void GanttViewElement_EditorInitialized(object sender, GanttViewItemEditorInitializedEventArgs e)
{
    GanttViewSpinEditor spinEditor = e.Editor as GanttViewSpinEditor;
    if (spinEditor != null)
    {
        spinEditor.ValueType = typeof(double);
    }
}


void GanttViewElement_EditorRequired(object sender, GanttViewEditorRequiredEventArgs e)
{
    if (e.EditorType == typeof(GanttViewSpinEditor))
    {
        e.EditorType = typeof(MySpinEditor);
    }
}
0 comments