Ext.NET icon indicating copy to clipboard operation
Ext.NET copied to clipboard

Ext.Net.Core.ExtModel.CustomConfig.Add(string, JsObject) throws NULL exception

Open fabriciomurta opened this issue 5 years ago • 0 comments

Found: 7.2.0 Ext.NET forums' thread: GridPanel Boolean data and Checkbox editor

The Ext.Net.Core.ExtModel.CustomConfig.Add(string, JsObject) method throws null reference exception if it is called to a component instance which its CustomConfig field is not explicitly initialized.

This may impose code pollution when the method could just initialize it if not so.

The following code reproduces the issue:

var col = new Ext.Net.CheckColumn()
{
    Text = "Really?",
    DataIndex = "really",
    Width = 50
};

col.CustomConfig.Add("editable", true);

To avoid the issue, two options are possible:

var col = new Ext.Net.CheckColumn()
{
    Text = "Really?",
    DataIndex = "really",
    Width = 50,
    CustomConfig = new Ext.Net.Core.JsObject()
};

col.CustomConfig.Add("editable", true);

```csharp
var col = new Ext.Net.CheckColumn()
{
    Text = "Really?",
    DataIndex = "really",
    Width = 50
};

col.CustomConfig = new Ext.Net.Core.JsObject
{
    { "editable", true }
};

fabriciomurta avatar Jan 15 '21 14:01 fabriciomurta