Mar 24, 2009, 9:04 AM
Editor.Add for grid column not working on 0.7?
Hi there,
I'm trying to create a grid programatically, all works very well until I start adding an editor to the columns, when I do that I get some errors.
Here's the chunk of code for adding the columns
If I leave it in I get
Any ideas?
Thanks in advance
I'm trying to create a grid programatically, all works very well until I start adding an editor to the columns, when I do that I get some errors.
Here's the chunk of code for adding the columns
foreach (DataColumn col in (dt.Columns))
{
Coolite.Ext.Web.Column webCol = new Coolite.Ext.Web.Column();
webCol.Header = col.ColumnName;
webCol.Sortable = true;
webCol.DataIndex = col.ColumnName;
webCol.Fixed = false;
Coolite.Ext.Web.TextField tfEditor = new Coolite.Ext.Web.TextField();
// tfEditor.ID = "txtEditor_" + col.Ordinal.ToString();
webCol.Editor.Add(tfEditor);
gpGrid.ColumnModel.Columns.Add(webCol);
Coolite.Ext.Web.RecordField field = new Coolite.Ext.Web.RecordField(col.ColumnName);
reader.Fields.Add(field);
}
dsStore.Reader.Clear();
dsStore.Reader.Add(reader);
//dsStore.DataSource = dt;
}
dsStore.DataBind();
If I comment out completely the WebCol.Editor.Add(tfEditor) line then all works well, but obviously I get no editors.If I leave it in I get
<h2> Object reference not set to an instance of an object. </h2>
Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
<table bgcolor="#ffffcc" width="100%">
<tbody><tr>
<td>
<code>
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.</code>
</td>
</tr>
</tbody></table>
Stack Trace:
<table bgcolor="#ffffcc" width="100%">
<tbody><tr>
<td>
<code></code>[NullReferenceException: Object reference not set to an instance of an object.]
Coolite.Ext.Web.ClientConfig.WriteValue(String name, Object value) +535
Coolite.Ext.Web.ClientConfig.ToExtConfig(PropertyInfo property, Object obj, ClientConfigAttribute attr, Object defaultValue) +2903
Coolite.Ext.Web.ClientConfig.Process(Object obj) +133
[Exception: Error during ClientConfig initialization. ClientID - Object reference not set to an instance of an object.]
Coolite.Ext.Web.ClientConfig.Process(Object obj) +231
Coolite.Ext.Web.ClientConfig.Serialize(Object obj, Boolean ignoreCustomSerialization) +641
Coolite.Ext.Web.ClientConfig.ToExtConfig(PropertyInfo property, Object obj, ClientConfigAttribute attr, Object defaultValue) +927
Coolite.Ext.Web.ClientConfig.Process(Object obj) +133
[Exception: Error during ClientConfig initialization. Editor - Error during ClientConfig initialization. ClientID - Object reference not set to an instance of an object.]
Coolite.Ext.Web.ClientConfig.Process(Object obj) +231
Coolite.Ext.Web.ClientConfig.Serialize(Object obj, Boolean ignoreCustomSerialization) +641
Coolite.Ext.Web.ClientConfig.ToExtConfig(PropertyInfo property, Object obj, ClientConfigAttribute attr, Object defaultValue) +1893
Coolite.Ext.Web.ClientConfig.Process(Object obj) +133
[Exception: Error during ClientConfig initialization. Columns - Error during ClientConfig initialization. Editor - Error during ClientConfig initialization. ClientID - Object reference not set to an instance of an object.]
Coolite.Ext.Web.ClientConfig.Process(Object obj) +231
Coolite.Ext.Web.ClientConfig.Serialize(Object obj, Boolean ignoreCustomSerialization) +641
Coolite.Ext.Web.WebControl.get_InitialConfig() +87
Coolite.Ext.Web.WebControl.GetClientConstructor(Boolean instanceOnly, String body) +318
Coolite.Ext.Web.InnerObservable.RegisterScript(Boolean inTop) +338
Coolite.Ext.Web.InnerObservable.ParentComponent_BeforeClientInit(Observable sender) +7
Coolite.Ext.Web.OnBeforeClientInitializedHandler.Invoke(Observable sender) +0
Coolite.Ext.Web.Observable.OnBeforeClientInitHandler() +26
Coolite.Ext.Web.Observable.OnClientInit() +12
Coolite.Ext.Web.WebControl.SetResources() +48
Coolite.Ext.Web.WebControl.PreRenderAction() +436
Coolite.Ext.Web.Container.OnPreRender(EventArgs e) +81
System.Web.UI.Control.PreRenderRecursiveInternal() +86
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Control.PreRenderRecursiveInternal() +170
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
</td></tr></tbody></table>
Now if I uncomment the line // tfEditor.ID = "txtEditor_" + col.Ordinal.ToString();
I don't get the error, but I get a javascript null reference error instead<div class="errorTitle ">C is null
<div class="errorSourceBox errorSource-exec ">
<div class="errorSourceBox errorSource-exec ">Ext.form.Field=Ext.extend(Ext.BoxCompone...ue})}}};Ext.reg("field",Ext.form.Field);
<a class="objectLink objectLink-sourceLink ">coolite.axd?9936 (line 123</a>)
I saw a similar thread but that said that the problem was fixed (was with property grids in that instance) in 0.7, but i'm already running 0.7 and getting this problem?Any ideas?
Thanks in advance