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

Customized column editing exception

2 Answers 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 01 Nov 2013, 04:19 PM
Please help me with this:

I have this problem between the old version and new version (2012.3.1038.40 vs 2013.3.1015.40)

I am using customized column editor (I want a drop-down, rather a free-style type field), pelase see the code in the end.

my question is, the following code works perfectly with version 2012.3.1038.40 (I know it is an old version)
but after I referred to the new Telerik.Web.UI with version 2013.3.1015.40, I got exception as below

[NullReferenceException: Object reference not set to an instance of an object.]
Telerik.Web.UI.GridTextBoxColumnEditor.CreateControls() +264
Telerik.Web.UI.GridColumnEditorBase.EnsureControlsCreated() +56
Telerik.Web.UI.GridColumnEditorBase.InitializeInControl(Control containerControl) +77
...
...

by setting debug line in customized editor class, I found out that with the new version, AddControlsToContainer() never get called

If I switch back the old DLL version, everything is just working fine.

we are desperately looking for help!!!
Just cannot upgrade any newer version

Thanks in advance


//Here is the event to create my own column editor
//
protected void RadGridMHomeMCM_CreateColumnEditor(object sender, GridCreateColumnEditorEventArgs e)
{
    if (e.Column is GridBoundColumn && e.Column.UniqueName.StartsWith("CAP"))
    {
        e.ColumnEditor = new ClsCustomDropDownList();
    }
}

//Here is my column editor class
//
private class ClsCustomDropDownList : GridTextBoxColumnEditor
{
    private RadComboBox ddlEditor;

    protected override void CreateControls()
    {
        this.ddlEditor = new RadComboBox();
        this.ddlEditor.Items.Add(new RadComboBoxItem("Yes", "Yes"));
        this.ddlEditor.Items.Add(new RadComboBoxItem("No", "No"));
    } 

    protected override void LoadControlsFromContainer()
    {
        this.ddlEditor = this.ContainerControl.Controls[0] as RadComboBox;
    }

    public override bool IsInitialized
    {
        get { return this.ddlEditor != null; }
    }

    public override string Text
    {
         get { return this.ddlEditor.Text; }
         set { this.ddlEditor.Text = value; }
    }

    protected override void AddControlsToContainer()
    {
         ddlEditor = new RadComboBox();
         ddlEditor.Items.Add(new RadComboBoxItem("Yes", "Yes"));
         ddlEditor.Items.Add(new RadComboBoxItem("No", "No"));

         this.EnsureControlsCreated(); 
         this.ContainerControl.Controls.Add(this.ddlEditor);
    }

}

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 06 Nov 2013, 12:34 PM
Hi Peter,

Thank you for contacting us.

I have tested the provided code on my end with both versions (2012.3.1038.40 vs 2013.3.1015.40) and a simple GridBoundColumn within the grid and I get "Object reference not set to an instance of an object" with both of them. However, the approach works as expected if I change the inherited class from GridTextBoxColumnEditor to GridTextColumnEditor.

Could you please try changing the inherited class with "GridTextColumnEditor" and see if it makes any difference. 

Furthermore, you could have a look at our help article "Custom Editors Extending Auto-Generated Editors".

If the above does not help in your scenario, please isolate a sample, runnable project that replicates the issue, so we could inspect it locally and provide you relevant to your exact scenario solution. 

Looking forward to your reply. 

 

Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Peter
Top achievements
Rank 1
answered on 06 Nov 2013, 04:32 PM
Yes sir, "GridTextColumnEditor" is working under newer version.
I guess "GridTextBoxColumnEditor" is working for the older version, or even if you get exception, it still managed through.
But for the newer version, it throw the exception.
Anyway, thanks you so much for your time and solution

Peter
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Peter
Top achievements
Rank 1
Share this question
or