[CLOSED] Layout School Part II: Three items inside ViewPort (with nested items)

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Layout School Part II: Three items inside ViewPort (with nested items)

    So, part II =) Thanks for the answer in Part I, I have based this example on Geoffreys answer in Part I.

    In this case I have a ViewPort (Layout="VBoxLayout"). Inside that ViewPort I have three items:
    - A Panel that wraps a ComboBox that I want to, as always, resize according to its parent container. Has LayoutConfig specified.
    - Another Panel. In my real world code I have here a UserControl that is a Form. In this scaled down example its just a bit of text. Should also extend all the width, and resize but doesnt.
    - A GridPanel. Same GridPanel as in Part I that should resize itself with its container. doesnt matter if I wrap it with a Panel or not.

    I have tried to "take in" some of the comments that Geoffrey made, but failed to make it work as expected anyways.

    I tried to wrap the GridPanel inside a Panel to get it to resize as in the example in Part I. That didnt work - it stays the same width as when the page was loaded, and the GridPanel does not expand downwards to show all three items. I have tried to add a LayoutConfig but if I do, the whole Panel/GridPanel disappears.

    What am I doing wrong?


    <%@ Page Language="C#" %>
       
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
       
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[] 
                { 
                    new object[] { "test11", "test12", "test13" },
                    new object[] { "test12", "test22", "test23" },
                    new object[] { "test13", "test32", "test33" }
                };
                 
                this.Store1.DataBind();
            }
        }
    </script>
       
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html>
    <head id="Head1" runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
         
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="test1" />
                            <ext:RecordField Name="test2" />
                            <ext:RecordField Name="test3" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
      
            <ext:Viewport ID="Viewport1" runat="server" Layout="VBoxLayout">
                <Items>
                    <ext:Panel ID="Panel3" runat="server" AutoScroll="true" RowHeight="1" Layout="FitLayout">
                        <LayoutConfig>
                            <ext:VBoxLayoutConfig Align="Stretch" />
                        </LayoutConfig>
                        <Items>
                            <ext:ComboBox runat="server" EmptyText="TestComboBox" Icon="User" DisplayField="CustomerName" ValueField="CustomerId">
                                <Items>
                                    <ext:ListItem Text="Test 1" Value="1" />
                                    <ext:ListItem Text="Test 2" Value="2" />
                                    <ext:ListItem Text="Test 3" Value="3" />
                                    <ext:ListItem Text="Test 4" Value="4" />
                                </Items>
                            </ext:ComboBox>
                        </Items>
                        <BottomBar>
                            <ext:Toolbar ID="Toolbar5" runat="server">
                                <Items>
                                    <ext:Button ID="Button5" runat="server" Icon="Anchor" Text="Bla bla"></ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </BottomBar>
                    </ext:Panel>
    
                    <ext:Panel ID="Panel4" runat="server" AutoScroll="true" Layout="FitLayout">
                        <Items> 
                            <ext:TextArea runat="server" Text="testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>"></ext:TextArea>
                        </Items>
                    </ext:Panel>
    
                    <ext:Panel ID="Panel1" runat="server" Layout="FitLayout">
                        <Items> 
                            <ext:GridPanel ID="GridPanel5" runat="server" StoreID="Store1" StripeRows="true" Header="true" Border="true">
                                <TopBar>
                                    <ext:Toolbar ID="Toolbar6" runat="server">
                                        <Items>
                                            <ext:Button ID="btnCreateNewCustomer" runat="server" Icon="Add" Text="Test button2"></ext:Button>
                                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                            <ext:Button ID="Button_CustomersRefresh" runat="server" Icon="ArrowRefresh" Text="Refresh"></ext:Button>
                                        </Items>
                                    </ext:Toolbar>
                                </TopBar>
                                <ColumnModel ID="ColumnModel5" runat="server">
                                    <Columns>
                                        <ext:Column Header="Test1" DataIndex="test1" />
                                        <ext:Column Header="Test2" DataIndex="test2" />
                                        <ext:Column Header="Test3" DataIndex="test3" />
                                    </Columns>
                                </ColumnModel>
                                <View>
                                    <ext:GridView ID="GridView5" runat="server" ForceFit="true" />
                                </View>
                            </ext:GridPanel>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    Last edited by Daniil; May 19, 2011 at 1:04 PM. Reason: [CLOSED]
  2. #2
    Hi,

    1. On "Panel3" you've added the VBoxLayoutConfig, although you've set .Layout="FitLayout". You can remove the VBoxLayoutConfig from "Panel3".

    2. On "Viewport1" you should add the VBoxLayoutConfig. Cut from "Panel3" and paste in "Viewport1".

    3. Add .Flex="1" to each of the three Containers within the Viewport <Items> Collection.

    Here's your sample with the three changes.

    Example

    <%@ Page Language="C#" %>
        
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
        
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[] 
                { 
                    new object[] { "test11", "test12", "test13" },
                    new object[] { "test12", "test22", "test23" },
                    new object[] { "test13", "test32", "test33" }
                };
                  
                this.Store1.DataBind();
            }
        }
    </script>
        
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <html>
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
          
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="test1" />
                            <ext:RecordField Name="test2" />
                            <ext:RecordField Name="test3" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
       
            <ext:Viewport runat="server" Layout="VBoxLayout">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
                <Items>
                    <ext:Panel runat="server" AutoScroll="true" RowHeight="1" Layout="FitLayout" Flex="1">
                        <Items>
                            <ext:ComboBox runat="server" EmptyText="TestComboBox" Icon="User" DisplayField="CustomerName" ValueField="CustomerId">
                                <Items>
                                    <ext:ListItem Text="Test 1" Value="1" />
                                    <ext:ListItem Text="Test 2" Value="2" />
                                    <ext:ListItem Text="Test 3" Value="3" />
                                    <ext:ListItem Text="Test 4" Value="4" />
                                </Items>
                            </ext:ComboBox>
                        </Items>
                        <BottomBar>
                            <ext:Toolbar runat="server">
                                <Items>
                                    <ext:Button runat="server" Icon="Anchor" Text="Bla bla" />
                                </Items>
                            </ext:Toolbar>
                        </BottomBar>
                    </ext:Panel>
     
                    <ext:Panel runat="server" AutoScroll="true" Layout="FitLayout" Flex="1">
                        <Items> 
                            <ext:TextArea runat="server" Text="testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>"></ext:TextArea>
                        </Items>
                    </ext:Panel>
     
                    <ext:Panel runat="server" Layout="FitLayout" Flex="1">
                        <Items> 
                            <ext:GridPanel runat="server" StoreID="Store1" StripeRows="true" Header="true" Border="true">
                                <TopBar>
                                    <ext:Toolbar runat="server">
                                        <Items>
                                            <ext:Button runat="server" Icon="Add" Text="Test button2" />
                                            <ext:ToolbarFill runat="server" />
                                            <ext:Button runat="server" Icon="ArrowRefresh" Text="Refresh" />
                                        </Items>
                                    </ext:Toolbar>
                                </TopBar>
                                <ColumnModel runat="server">
                                    <Columns>
                                        <ext:Column Header="Test1" DataIndex="test1" />
                                        <ext:Column Header="Test2" DataIndex="test2" />
                                        <ext:Column Header="Test3" DataIndex="test3" />
                                    </Columns>
                                </ColumnModel>
                                <View>
                                    <ext:GridView runat="server" ForceFit="true" />
                                </View>
                            </ext:GridPanel>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    The following example can be helpful for reviewing the HBoxLayout functionality and properties, see

    https://examples1.ext.net/#/Layout/VBoxLayout/Basic/
    Geoffrey McGill
    Founder
  4. #4
    As well, I would recommend a quick review of the HBox Layout docs, see

    http://dev.sencha.com/deploy/ext-3.3...ut&member=flex
    Geoffrey McGill
    Founder
  5. #5
    Thanks for that!

    If I want the top ComboBox GridPanel to just fit the ComboBox (height-wise) - how do I do that? I tried setting .Height on "Panel1" but then the height became 0 instead. I guess that has to do that its inside a VBoxLayout? The RowHeight is set to 1, so thats 100% Im guessing. If I dont want it to be a floating value, but instead a fixed nbr of pixels - how can I do that?
  6. #6
    I took a look at the example and sencha docs.

    Another question:

    The middle TextArea - why does those scrollbars appear? there is obviously a lot of space left for text as can be seen in the image below...

    Click image for larger version. 

Name:	delme.png 
Views:	216 
Size:	44.2 KB 
ID:	2740
  7. #7
    Quote Originally Posted by wagger View Post
    Thanks for that!

    If I want the top ComboBox GridPanel to just fit the ComboBox (height-wise) - how do I do that? I tried setting .Height on "Panel1" but then the height became 0 instead. I guess that has to do that its inside a VBoxLayout? The RowHeight is set to 1, so thats 100% Im guessing. If I dont want it to be a floating value, but instead a fixed nbr of pixels - how can I do that?
    Sorry, but I don't understand.

    If you want to set the .Height of a Panel in the HBoxLayout, remove the .Flex property and set .Height.
    Geoffrey McGill
    Founder
  8. #8
    Quote Originally Posted by wagger View Post
    I took a look at the example and sencha docs.

    Another question:

    The middle TextArea - why does those scrollbars appear? there is obviously a lot of space left for text as can be seen in the image below...

    Click image for larger version. 

Name:	delme.png 
Views:	216 
Size:	44.2 KB 
ID:	2740
    I'm not really sure why Chrome is adding the extra space for the scroll bars. Seems like IE, Firefox and Chrome all handle this differently.
    Geoffrey McGill
    Founder
  9. #9
    Quote Originally Posted by geoffrey.mcgill View Post
    Sorry, but I don't understand.

    If you want to set the .Height of a Panel in the HBoxLayout, remove the .Flex property and set .Height.
    Well, I tried to do just that; in "Panel1" I removed the Flex and set height, but then the height became 0 or perhaps 1. (note that is is a VBoxLayout, not HBoxLayout).

    here is the full example again, with that Flex removed and .Height set. Doesnt work, see this picture:
    Click image for larger version. 

Name:	delme.png 
Views:	145 
Size:	36.7 KB 
ID:	2741

    (As a side-comment; I am at the same time we are dealing with these examples trying to modify my live code to make the layout work better, but that usually fails. Even though the example below is actually a simplified layout of something I use, I cannot get it right in the real-live example. More on that later)

    Im off to bed now, so I'll reply in the morning =)

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
         
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[] 
                { 
                    new object[] { "test11", "test12", "test13" },
                    new object[] { "test12", "test22", "test23" },
                    new object[] { "test13", "test32", "test33" }
                };
                   
                this.Store1.DataBind();
            }
        }
    </script>
         
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
    <html>
    <head id="Head1" runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
           
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="test1" />
                            <ext:RecordField Name="test2" />
                            <ext:RecordField Name="test3" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
        
            <ext:Viewport ID="Viewport1" runat="server" Layout="VBoxLayout">
                <LayoutConfig>
                    <ext:VBoxLayoutConfig Align="Stretch" />
                </LayoutConfig>
                <Items>
                    <ext:Panel ID="Panel1" runat="server" AutoScroll="true" Height="30" Layout="FitLayout">
                        <Items>
                            <ext:ComboBox ID="ComboBox1" runat="server" EmptyText="TestComboBox" Icon="User" DisplayField="CustomerName" ValueField="CustomerId" >
                                <Items>
                                    <ext:ListItem Text="Test 1" Value="1" />
                                    <ext:ListItem Text="Test 2" Value="2" />
                                    <ext:ListItem Text="Test 3" Value="3" />
                                    <ext:ListItem Text="Test 4" Value="4" />
                                </Items>
                            </ext:ComboBox>
                        </Items>
                        <BottomBar>
                            <ext:Toolbar ID="Toolbar1" runat="server">
                                <Items>
                                    <ext:Button ID="Button1" runat="server" Icon="Anchor" Text="Bla bla" />
                                </Items>
                            </ext:Toolbar>
                        </BottomBar>
                    </ext:Panel>
      
                    <ext:Panel ID="Panel2" runat="server" AutoScroll="true" Layout="FitLayout" Flex="1">
                        <Items> 
                            <ext:TextArea ID="TextArea1" runat="server" Text="testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>testing testing<br><br>Test 2 test 2<br><br>"></ext:TextArea>
                        </Items>
                    </ext:Panel>
      
                    <ext:Panel ID="Panel3" runat="server" Layout="FitLayout" Flex="1">
                        <Items> 
                            <ext:GridPanel ID="GridPanel1" runat="server" StoreID="Store1" StripeRows="true" Header="true" Border="true">
                                <TopBar>
                                    <ext:Toolbar ID="Toolbar2" runat="server">
                                        <Items>
                                            <ext:Button ID="Button2" runat="server" Icon="Add" Text="Test button2" />
                                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                                            <ext:Button ID="Button3" runat="server" Icon="ArrowRefresh" Text="Refresh" />
                                        </Items>
                                    </ext:Toolbar>
                                </TopBar>
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:Column Header="Test1" DataIndex="test1" />
                                        <ext:Column Header="Test2" DataIndex="test2" />
                                        <ext:Column Header="Test3" DataIndex="test3" />
                                    </Columns>
                                </ColumnModel>
                                <View>
                                    <ext:GridView ID="GridView1" runat="server" ForceFit="true" />
                                </View>
                            </ext:GridPanel>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
  10. #10
    Hi,

    Height=30 is too small because you have combo and toolbar. Please increase the height and remove AutoScroll from the panel because autoscroll cannot be used with FitLayout
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: Jul 12, 2012, 2:06 PM
  2. [CLOSED] Layout School Part III: Why doesnt the UserControl show up
    By wagger in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: May 20, 2011, 8:10 AM
  3. Replies: 3
    Last Post: May 18, 2011, 7:06 PM
  4. [CLOSED] Items not showing as part of Ext.form.CompositeField
    By joeRobee in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 10, 2010, 7:27 PM
  5. Replies: 4
    Last Post: Jun 24, 2010, 11:09 PM

Tags for this Thread

Posting Permissions