[CLOSED] how to get number of panels in the window?

  1. #1

    [CLOSED] how to get number of panels in the window?

    <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)
                {
                    var n = (int)nf_doc.Number;
    
                    int c = w_docwin.Items.Count;//how to get panel number in the w_docwin window?
                    
                    if (n > c)  //if n>c 
                    {
                        for (int i = 0; i < n-c; i++)  //add number of n-c panels until its number is n;
                        {
                            var p = new Ext.Net.Panel();
                            var tf = new TextField { FieldLabel = "附件名称" };
                            var tf1 = new TextField { FieldLabel = "附件描述" };
                            var tf2 = new TextField { FieldLabel = "其他描述" };
                            var upload = new FileUploadField { FieldLabel = "文件", ButtonText = "浏览" };
    
                            p.Items.Add(tf);
                            p.Items.Add(tf1);
                            p.Items.Add(tf2);
                            p.Items.Add(upload);
                            w_docwin.Items.Add(p);
                            p.Render();
                        }
                    } 
                    w_docwin.Show();
                }
    Last edited by Daniil; Jun 11, 2013 at 4:20 AM. Reason: [CLOSED]
  2. #2
    Hi @tobros,

    If you render something during one DirectEvent, it is absolutely unknown during another DirectEvent unless you recreate it manually.

    You can store required info somewhere (for example, in Session) during initial rendering of dynamic controls. Another approach (and I like it much more) send required info from client side as an extra parameter of a DirectEvent.
    win.items.getCount();
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @tobros,

    If you render something during one DirectEvent, it is absolutely unknown during another DirectEvent unless you recreate it manually.

    You can store required info somewhere (for example, in Session) during initial rendering of dynamic controls. Another approach (and I like it much more) send required info from client side as an extra parameter of a DirectEvent.
    win.items.getCount();
    not getCount method
  4. #4
    How exactly are you trying?
  5. #5
    Quote Originally Posted by Daniil View Post
    How exactly are you trying?
    protected void e_doclick(object sender, DirectEventArgs e)
            {
    
                if (nf_doc.Value != null)
                {
                    var n = (int)nf_doc.Number;
    
                    int c = w_docwin.Items.Count;//how to get panel number in the w_docwin window?
                    w_docwin.Items.getCount();//not getCount method
                    if (n > c)
                    {
                        for (int i = 0; i < n-c; i++)
                        {
                            var p = new Ext.Net.Panel();
                            var tf = new TextField { FieldLabel = "附件名称" };
                            var tf1 = new TextField { FieldLabel = "附件描述" };
                            var tf2 = new TextField { FieldLabel = "其他描述" };
                            var upload = new FileUploadField { FieldLabel = "文件", ButtonText = "浏览" };
    
                            p.Items.Add(tf);
                            p.Items.Add(tf1);
                            p.Items.Add(tf2);
                            p.Items.Add(upload);
                            w_docwin.Items.Add(p);
                            p.Render();
                        }
                    } 
                    w_docwin.Show();
                }
  6. #6
    Hello!

    If window items is static you can identify them on the server-side, but if window has dynamic items you should send them from client side:

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET Examples</title>
    
        <script runat="server">
            public void Click(object sender, DirectEventArgs e)
            {
                X.Msg.Alert("Count", string.Format("Server side items count = {0}; Client side items count = {1}", Window1.Items.Count(), e.ExtraParams["count"])).Show();
            }
        </script>
        
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:Window runat="server" Layout="HBox" Width="600" Height="400" ID="Window1">
            <LayoutConfig>
                <ext:HBoxLayoutConfig Align="Stretch"/>
            </LayoutConfig>
            <Items>
                <ext:Panel runat="server" ID="Panel1" Height="100" Flex="1"></ext:Panel>
                <ext:Panel runat="server" ID="Panel2" Height="100" Flex="1"></ext:Panel>
                <ext:Panel runat="server" ID="Panel3" Height="100" Flex="1"></ext:Panel>
                <ext:Panel runat="server" ID="Panel4" Height="100" Flex="1"></ext:Panel>
            </Items>
            <Buttons>
                <ext:Button runat="server" Text="Click me   ">
                    <DirectEvents>
                        <Click OnEvent="Click">
                            <ExtraParams>
                                <ext:Parameter Name="count" Value="#{Window1}.items.getCount()" Mode="Raw" />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:Window>
    </body>
    </html>
    int c = w_docwin.Items.Count;
    This code should work. Variable c should contain items count. You don't need to call GetCount method

Similar Threads

  1. [CLOSED] So many panels and nested panels
    By thchuong in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 03, 2012, 5:23 AM
  2. [CLOSED] panels fit completely in a window
    By marco.morreale in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 31, 2012, 2:43 PM
  3. Replies: 0
    Last Post: Aug 30, 2011, 2:48 PM
  4. License Number?
    By jcanton in forum Licensing
    Replies: 2
    Last Post: Jul 12, 2011, 1:55 PM
  5. Number Field
    By fabiomarcos in forum 1.x Help
    Replies: 2
    Last Post: Jan 20, 2009, 11:29 AM

Posting Permissions