Jan 06, 2012, 9:20 AM
Custom Control. Type of custom property is array of string values
Hello,
I'm trying to create custom ext.net control which based on Panel with custom property "Groups". This property should be an array of string values
( groups: ["aaa", "bbb"] ).
I'de like to see next structure on design mode:
How do I configure Groups property or classes to get an array of string on client side?
I'm trying to create custom ext.net control which based on Panel with custom property "Groups". This property should be an array of string values
( groups: ["aaa", "bbb"] ).
I'de like to see next structure on design mode:
<ux:MyPanel runat="server">
<Groups>
<ux:Group Name="aaa" />
<ux:Group Name="bbb" />
</Groups>
</ux:MyPanel>
Custom control codebehind:// Custom control
public partial class MyPanel : Panel
{
private GroupCollection groups;
[ConfigOption("groups", JsonMode.AlwaysArray)]
[Category("Config Options")]
[DefaultValue(null)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[ViewStateMember]
public virtual GroupCollection Groups
{
get
{
if (this.groups == null)
{
this.groups = new GroupCollection();
this.groups.TrackViewState();
}
return this.groups;
}
}
}
public partial class MyPanel
{
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[XmlIgnore]
[JsonIgnore]
public override ConfigOptionsCollection ConfigOptions
{
get
{
ConfigOptionsCollection list = base.ConfigOptions;
list.Add("groupField", new ConfigOption("groups", new SerializationOptions("groups", JsonMode.AlwaysArray), null, this.Groups));
return list;
}
}
}
// Groups collection
public partial class Group : StateManagedItem
{
[DefaultValue("")]
[NotifyParentProperty(true)]
[Description("The grouping fieldname")]
public string FieldName
{
get
{
object obj = this.ViewState["FieldName"];
return obj != null ? (string)obj : string.Empty;
}
set
{
this.ViewState["FieldName"] = value;
}
}
public override string ToString()
{
return FieldName;
}
}
public class GroupCollection : StateManagedCollection<Group> { }
But I get array of empty objects on client side ( groups: [{}, {}] ) or array of not empty objects (groups: [{group: 'aaa'}, {group: 'bbb'}]) if I override ConfigOptions for Group .How do I configure Groups property or classes to get an array of string on client side?