PDA

View Full Version : [CLOSED] how to insert panel to an window?



tobros
Jun 03, 2013, 7:32 AM
<ext:Window runat="server" Width="320" ID="w_docwin" Hidden="True" Modal="True" Title="附件管理" Layout="AccordionLayout">
</ext:Window>

<ext:NumberField Icon="TextListNumbers" ID="nf_doc" runat="server" InputWidth="60" EmptyText="0">
<DirectEvents>
<IconClick OnEvent="e_doclick"></IconClick>
</DirectEvents>

</ext:NumberField>



protected void e_doclick(object sender, DirectEventArgs e)
{
if (nf_doc.Value != null)
{
int n = int.Parse(nf_doc.Value.ToString());
var p = new Ext.Net.Panel();

var tf = new TextField {FieldLabel = "附件名称"};
var tf1 = new TextField { FieldLabel = "附件描述" };
var tf2 = new TextField { FieldLabel = "其他描述" };
p.Items.Add(tf);
p.Items.Add(tf1);
p.Items.Add(tf2);
for (int i = 0; i < n; i++)
{
// w_docwin.Items.Insert(i,p);
p.InsertTo(i, w_docwin);
}
}
w_docwin.Show();
}

why only insert one panel to the window?

ViDom
Jun 03, 2013, 10:28 AM
<ext:Window runat="server" Width="320" ID="w_docwin" Hidden="True" Modal="True" Title="附件管理" Layout="AccordionLayout">
</ext:Window>

<ext:NumberField Icon="TextListNumbers" ID="nf_doc" runat="server" InputWidth="60" EmptyText="0">
<DirectEvents>
<IconClick OnEvent="e_doclick"></IconClick>
</DirectEvents>

</ext:NumberField>



protected void e_doclick(object sender, DirectEventArgs e)
{
if (nf_doc.Value != null)
{
int n = int.Parse(nf_doc.Value.ToString());
var p = new Ext.Net.Panel();

var tf = new TextField {FieldLabel = "附件名称"};
var tf1 = new TextField { FieldLabel = "附件描述" };
var tf2 = new TextField { FieldLabel = "其他描述" };
p.Items.Add(tf);
p.Items.Add(tf1);
p.Items.Add(tf2);
for (int i = 0; i < n; i++)
{
// w_docwin.Items.Insert(i,p);
p.InsertTo(i, w_docwin);
}
}
w_docwin.Show();
}

why only insert one panel to the window?

Hi,
Please try:


protected void e_doclick(object sender, DirectEventArgs e)
{
if (nf_doc.Value != null)
{
int n = int.Parse(nf_doc.Value.ToString());
Ext.Net.Panel p ;

for (int i = 0; i < n; i++)
{
p= new Ext.Net.Panel();
var tf = new TextField {FieldLabel = "附件名称"};
var tf1 = new TextField { FieldLabel = "附件描述" };
var tf2 = new TextField { FieldLabel = "其他描述" };
p.Items.Add(tf);
p.Items.Add(tf1);
p.Items.Add(tf2);
w_docwin.Items.Insert(i,p);

}
}
w_docwin.Show();
}

If it will not show more than 1 panel please use Render() method on each panel after insert it in w_docwin

Daniil
Jun 03, 2013, 1:33 PM
Hi,

A control cannot be rendered twice or more times.

Calling a control's InsertTo method means that a control renders to client.

You should slightly change the logic creating a new Panel instance for each InsertTo.

By the way, you can use

int n = (int)nf_doc.Number;
instead of

int n = int.Parse(nf_doc.Value.ToString());

ViDom
Jun 03, 2013, 3:26 PM
Hi,

A control cannot be rendered twice or more times.

Calling a control's InsertTo method means that a control renders to client.

You should slightly change the logic creating a new Panel instance for each InsertTo.

By the way, you can use

int n = (int)nf_doc.Number;
instead of

int n = int.Parse(nf_doc.Value.ToString());

but each time there will be a new Panel control or am I missing something?

Daniil
Jun 03, 2013, 3:31 PM
but each time there will be a new Panel control or am I missing something?

Well, yes.

tobros
Jun 04, 2013, 1:09 AM
hi


protected void e_doclick(object sender, DirectEventArgs e)
{
if (nf_doc.Value != null)
{
int n = (int)nf_doc.Number;

for (int i = 0; i < n; i++)
{
var p = new Ext.Net.Panel();
var tf = new TextField { FieldLabel = "附件名称" };
var tf1 = new TextField { FieldLabel = "附件描述" };
var tf2 = new TextField { FieldLabel = "其他描述" };
p.Items.Add(tf);
p.Items.Add(tf1);
p.Items.Add(tf2);
w_docwin.Items.Insert(i, p);
p.Render();//why must add this?
}

}
w_docwin.Show();
}

it is ok now, but why p.Render(); ?

Daniil
Jun 04, 2013, 3:36 AM
p.Render();//why must add this?

Putting a control into a container's Items collection is not enough to render that control during a DirectEvent.

By the way, you can still use the InsertTo method, replacing this

w_docwin.Items.Insert(i, p);
p.Render();//why must add this?
with

p.InsertTo(0, w_docwin);

There is also the AddTo method.