Oct 02, 2012, 8:41 PM
Forcing panel layout inside menu
I'm creating an element in code-behind like so:
[ParseChildren(ChildrenAsProperties=true)]
public class MarkdownTextArea : Panel
{
protected override void OnInit(EventArgs e)
{
this.Border = false;
this.Layout = "FitLayout";
this.Items.Add(new TextArea
{
ID = "MDArea",
IDMode = Ext.Net.IDMode.Explicit,
ClientIDMode = System.Web.UI.ClientIDMode.Static,
AllowBlank = false,
MinLength = 10,
MinLengthText = this.MinLengthText,
EmptyText = this.MinLengthText
});
Toolbar toolbar = new Toolbar();
AddSnippetButton(toolbar);
this.TopBar.Add(toolbar);
base.OnInit(e);
}
private void AddSnippetButton(Toolbar toolbar)
{
Button snippetButton = new Button
{
ToolTip = "Insert a snippet",
Icon = Icon.Comment,
};
Menu snippetMenu = new Menu();
long id = 1;
Panel snippetPanel = CreateSnippetPanel(id);
snippetMenu.Items.Add(snippetPanel);
snippetButton.Menu.Add(snippetMenu);
toolbar.Items.Add(snippetButton);
}
private Panel CreateSnippetPanel(long idFor)
{
Panel p = new Panel();
p.IDMode = Ext.Net.IDMode.Explicit;
p.ID = ID + "_SnippetPicker";
p.Width = 600;
p.Height = 250;
p.Title = "Select a snippet";
p.Layout = "AnchorLayout";
ColumnLayout layout = new ColumnLayout();
LayoutColumn left = new LayoutColumn
{
ColumnWidth = 0.45M
};
left.Items.Add(new MyCustomTreeGrid
{
ID = ID + "_SnippetGrid",
IDMode = Ext.Net.IDMode.Explicit,
RootEntityId = idFor,
RootEntityText = "Snippets",
});
layout.Columns.Add(left);
LayoutColumn right = new LayoutColumn
{
ColumnWidth = 0.55M
};
right.Items.Add(new DisplayField
{
Text = "test",
});
layout.Columns.Add(right);
layout.Split = true;
p.Items.Add(layout);
return p;
}
}
The idea is that you click the menu button and the column layout panel is displayed there. When I click the menu button only the left panel with the TreePanel control is shown and it has not been initialized (i.e. the nodes have not been loaded). I tried setting ForceLayout=true on the panel inside CreateSnippetPanel but it does not seem to have had any effect.
Last edited by cmv; Oct 02, 2012 at 8:50 PM.