Dec 23, 2013, 10:24 AM
[CLOSED] Custom grid with addtional columns
Hello.
I have created a class, which inherited from the GridPanel. In the javascript constructor of this grid, I populated default config of the grid. I want to create a AdditionalColumns property, which should works like ColumnModel. For that I right the following structure
a) Standard markup without additional columns
b) Standard markup with additional columns
c) a) + b) for case, when MyGrid is a part of the complex control, which is dynamically loaded using LoadControl method.
In variant mentioned above this control rises error in case c), because the following config is generated
"ItemTag validation (_tkn_134): Reference token (phContent_phToolsContent_ctl191_ClientInit) was not found."
Could you, please, suggest how can I fix my code to avoid errors for all cases?
Best regards.
I have created a class, which inherited from the GridPanel. In the javascript constructor of this grid, I populated default config of the grid. I want to create a AdditionalColumns property, which should works like ColumnModel. For that I right the following structure
public class MyGrid: GridPanel
{
[Meta]
[ConfigOption]
[DefaultValue(0)]
[NotifyParentProperty(true)]
public override ConfigOptionsCollection ConfigOptions
{
get
{
// This check is need for dynamic control loading, using LoadControl
//if (this.AdditionalColumns.Columns.Count > 0)
//{
list.Add("additionalColumns", new ConfigOption("additionalColumns", new SerializationOptions("additionalColumns", typeof(LazyControlJsonConverter)), null, this.AdditionalColumns));
//}
return list;
}
}
private GridHeaderContainer additionalColumns;
[Meta]
[ConfigOption("columns", typeof(LazyControlJsonConverter))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("Column definitions which define all columns that appear in this grid. Each column definition provides the header text for the column, and a definition of where the data for that column comes from.")]
public virtual GridHeaderContainer AdditionalColumns
{
get
{
if (this.additionalColumns == null)
{
this.additionalColumns = new GridHeaderContainer();
this.Controls.Add(this.additionalColumns);
this.LazyItems.Add(this.additionalColumns);
}
return this.additionalColumns;
}
}
}
This control is used in different cases:a) Standard markup without additional columns
b) Standard markup with additional columns
c) a) + b) for case, when MyGrid is a part of the complex control, which is dynamically loaded using LoadControl method.
In variant mentioned above this control rises error in case c), because the following config is generated
{
xtype: 'mygrid',
additionalColumns: /*there is no eny object here*/
}
I tried to add if (this.AdditionalColumns.Columns.Count > 0)
check, which is commented above. Then case c) is going to work, but case a) failed with the error"ItemTag validation (_tkn_134): Reference token (phContent_phToolsContent_ctl191_ClientInit) was not found."
Could you, please, suggest how can I fix my code to avoid errors for all cases?
Best regards.
Last edited by Daniil; Dec 23, 2013 at 11:28 AM.
Reason: [CLOSED]