[CLOSED] FileUploadField layout issue using CardLayout

  1. #1

    [CLOSED] FileUploadField layout issue using CardLayout

    Hi,

    Please consider the code snippet below. It's very simple but shows a similar layout issue I'm having with FileUploadField in a much more involved scenario. The "Upload" button is far removed from the input field. In my setting, I've tried to replace the horizontal anchor with width and played a bit with panel layout, which didn't help. I'm running this code sample in IE9. Please suggest how to remedy it properly or advise if more info is required or if the issue isn't reproducible.

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Next_Click(object sender, DirectEventArgs e)
        {
            int index = int.Parse(e.ExtraParams["index"]);
    
            if ((index + 1) < this.WizardPanel.Items.Count)
            {
                this.WizardPanel.ActiveIndex = index + 1;
            }
    
            this.CheckButtons();
        }
    
        protected void Prev_Click(object sender, DirectEventArgs e)
        {
            int index = int.Parse(e.ExtraParams["index"]);
    
            if ((index - 1) >= 0)
            {
                this.WizardPanel.ActiveIndex = index - 1;
            }
    
            this.CheckButtons();
        }
    
        private void CheckButtons()
        {
            int index = this.WizardPanel.ActiveIndex;
    
            this.btnNext.Disabled = index == (this.WizardPanel.Items.Count - 1);
            this.btnPrev.Disabled = index == 0;
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>CardLayout - Ext.NET Examples</title>
        <%--<link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />--%>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Panel ID="WizardPanel" runat="server" Title="Example Wizard" Padding="15" Height="300"
            Layout="card" ActiveIndex="0">
            <Items>
                <ext:Panel ID="Panel1" runat="server" Border="false" Header="false">
                    <Items>
                        <ext:FileUploadField runat="server" AnchorHorizontal="90%" HideLabel="true">
                        </ext:FileUploadField>
                    </Items>
                </ext:Panel>
                <ext:Panel ID="Panel2" runat="server" Html="<h1>Card 2</h1><p>Step 2 of 3</p>" Border="false"
                    Header="false" />
                <ext:Panel ID="Panel3" runat="server" Html="<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>"
                    Border="false" Header="false" />
            </Items>
            <Buttons>
                <ext:Button ID="btnPrev" runat="server" Text="Prev" Disabled="true" Icon="PreviousGreen">
                    <DirectEvents>
                        <Click OnEvent="Prev_Click">
                            <ExtraParams>
                                <ext:Parameter Name="index" Value="#{WizardPanel}.items.indexOf(#{WizardPanel}.layout.activeItem)"
                                    Mode="Raw" />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button ID="btnNext" runat="server" Text="Next" Icon="NextGreen">
                    <DirectEvents>
                        <Click OnEvent="Next_Click">
                            <ExtraParams>
                                <ext:Parameter Name="index" Value="#{WizardPanel}.items.indexOf(#{WizardPanel}.layout.activeItem)"
                                    Mode="Raw" />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:Panel>
        </form>
    </body>
    </html>
    Attached Thumbnails Click image for larger version. 

Name:	Layout Issue.JPG 
Views:	104 
Size:	32.7 KB 
ID:	5415  
    Last edited by Baidaly; Jan 14, 2013 at 1:17 AM. Reason: [CLOSED]
  2. #2
    Hello!

    Please, try to set layout to form:

    <ext:Panel ID="Panel1" runat="server" Border="false" Header="false" Layout="Form">
    	<Items>
    		<ext:FileUploadField runat="server" AnchorHorizontal="90%" HideLabel="true">
    		</ext:FileUploadField>
    	</Items>
    </ext:Panel>
  3. #3
    OK, here's a more realistic example reproducing my issue. Note that the AfterRender listener is implemented to remove card flickering when it's revealed the first time. This workaround was suggested by Daniil in http://forums.ext.net/showthread.php...ith-CardLayout some time ago and has since worked well in our many UI compositions. However, it's this event handler that causes the layout issue with FileUploadField. Try to comment it out for the second card to see the issue disappear.

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Next_Click(object sender, DirectEventArgs e)
        {
            int index = int.Parse(e.ExtraParams["index"]);
    
            if ((index + 1) < this.WizardPanel.Items.Count)
            {
                this.WizardPanel.ActiveIndex = index + 1;
            }
    
            this.CheckButtons();
        }
    
        protected void Prev_Click(object sender, DirectEventArgs e)
        {
            int index = int.Parse(e.ExtraParams["index"]);
    
            if ((index - 1) >= 0)
            {
                this.WizardPanel.ActiveIndex = index - 1;
            }
    
            this.CheckButtons();
        }
    
        private void CheckButtons()
        {
            int index = this.WizardPanel.ActiveIndex;
    
            this.btnNext.Disabled = index == (this.WizardPanel.Items.Count - 1);
            this.btnPrev.Disabled = index == 0;
        }
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>CardLayout - Ext.NET Examples</title>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="FormLayout">
            <Items>
                <ext:Button runat="server" Text="Show Window">
                    <Listeners>
                        <Click Handler="#{Window1}.show();" />
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Viewport>
        <ext:Window ID="Window1" runat="server" Title="Modal Dialog" Height="650px" Hidden="true"
            Width="800px" BodyStyle="background-color: #fff;" Resizable="false" Padding="5"
            Collapsible="false" Modal="true">
            <Content>
                <ext:FitLayout runat="server">
                    <Items>
                        <ext:Panel ID="WizardPanel" runat="server" Title="Example Wizard" Padding="15" Height="300"
                            Layout="CardLayout" ActiveIndex="0">
                            <Items>
                                <ext:Panel runat="server" Border="false" Header="false" Layout="FormLayout">
                                    <Items>
                                        <ext:ColumnLayout runat="server" Split="false" FitHeight="true">
                                            <Columns>
                                                <ext:LayoutColumn ColumnWidth="0.25">
                                                    <ext:Panel runat="server" Html="<div style='font-weight:bold;font-size:9pt;margin:5px;margin-top:27px;'>Card 1:</div>" />
                                                </ext:LayoutColumn>
                                                <ext:LayoutColumn ColumnWidth="0.75">
                                                    <ext:Panel runat="server" Border="true" Frame="false" Layout="FormLayout"
                                                        Padding="24">
                                                        <Items>
                                                            <ext:TextField runat="server" FieldLabel="Some Text">
                                                            </ext:TextField>
                                                        </Items>
                                                    </ext:Panel>
                                                </ext:LayoutColumn>
                                            </Columns>
                                        </ext:ColumnLayout>
                                    </Items>
                                    <Listeners>
                                        <AfterRender Handler="this.setSize(this.ownerCt.layout.getLayoutTargetSize());
                                                        this.doLayout();" Delay="100" />
                                    </Listeners>
                                </ext:Panel>
                                <ext:Panel runat="server" Border="false" Header="false" Layout="FormLayout">
                                    <Items>
                                        <ext:ColumnLayout runat="server" Split="false" FitHeight="true">
                                            <Columns>
                                                <ext:LayoutColumn ColumnWidth="0.25">
                                                    <ext:Panel runat="server" Html="<div style='font-weight:bold;font-size:9pt;margin:5px;margin-top:27px;'>Card 2:</div>" />
                                                </ext:LayoutColumn>
                                                <ext:LayoutColumn ColumnWidth="0.75">
                                                    <ext:Panel runat="server" Border="true" Frame="false" Layout="FormLayout"
                                                        Padding="24">
                                                        <Items>
                                                            <ext:FileUploadField runat="server" AnchorHorizontal="100%"
                                                                HideLabel="true">
                                                            </ext:FileUploadField>
                                                        </Items>
                                                    </ext:Panel>
                                                </ext:LayoutColumn>
                                            </Columns>
                                        </ext:ColumnLayout>
                                    </Items>
                                    <Listeners>
                                        <AfterRender Handler="this.setSize(this.ownerCt.layout.getLayoutTargetSize());
                                                        this.doLayout();" Delay="100" />
                                    </Listeners>
                                </ext:Panel>
                            </Items>
                            <Buttons>
                                <ext:Button ID="btnPrev" runat="server" Text="Prev" Disabled="true" Icon="PreviousGreen">
                                    <DirectEvents>
                                        <Click OnEvent="Prev_Click">
                                            <ExtraParams>
                                                <ext:Parameter Name="index" Value="#{WizardPanel}.items.indexOf(#{WizardPanel}.layout.activeItem)"
                                                    Mode="Raw" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                                <ext:Button ID="btnNext" runat="server" Text="Next" Icon="NextGreen">
                                    <DirectEvents>
                                        <Click OnEvent="Next_Click">
                                            <ExtraParams>
                                                <ext:Parameter Name="index" Value="#{WizardPanel}.items.indexOf(#{WizardPanel}.layout.activeItem)"
                                                    Mode="Raw" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Buttons>
                        </ext:Panel>
                    </Items>
                </ext:FitLayout>
            </Content>
        </ext:Window>
        </form>
    </body>
    </html>
    Last edited by vadym.f; Jan 12, 2013 at 2:03 AM.
  4. #4
    Can you say for what are you doing this?

    <AfterRender Handler="this.setSize(this.ownerCt.layout.getLayoutTargetSize());
    	this.doLayout();" Delay="100" />
    Because without this everything works fine
  5. #5
    Quote Originally Posted by Baidaly View Post
    Can you say for what are you doing this?

    <AfterRender Handler="this.setSize(this.ownerCt.layout.getLayoutTargetSize());
    	this.doLayout();" Delay="100" />
    Because without this everything works fine
    That was my point :) This workaround was put in place to remove hidden card flickering on the first selection. Comment it out in the second panel to see the difference. When it's selected the first time, it flickers momentarily to complete its layout. I'd like to make adjustments to the handler code so it still works as before and doesn't present new layout issues with controls.
  6. #6
    OK. Try to doLayout again when the second panel shows up:

    <ext:Panel runat="server" Border="false" Header="false" Layout="FormLayout">
    	<Items>
    		<ext:ColumnLayout runat="server" Split="false" FitHeight="true">
    			<Columns>
    				<ext:LayoutColumn ColumnWidth="0.25">
    					<ext:Panel runat="server" Html="<div style='font-weight:bold;font-size:9pt;margin:5px;margin-top:27px;'>Card 2:</div>" />
    				</ext:LayoutColumn>
    				<ext:LayoutColumn ColumnWidth="0.75">
    					<ext:Panel runat="server" Border="true" Frame="false" Layout="FormLayout"
    						Padding="24">
    						<Items>
    							<ext:FileUploadField runat="server" AnchorHorizontal="100%"
    								HideLabel="true">
    							</ext:FileUploadField>
    						</Items>
    					</ext:Panel>
    				</ext:LayoutColumn>
    			</Columns>
    		</ext:ColumnLayout>
    	</Items>
    	<Listeners>
    		<AfterRender Handler="this.setSize(this.ownerCt.layout.getLayoutTargetSize());
    						this.doLayout();" Delay="100" />
    		<Show Handler="this.doLayout();" Single="True"></Show>
    	</Listeners>
    </ext:Panel>
  7. #7
    Sorry, I didn't notice any difference in behavior. Was this line the only change?

    <Show Handler="this.doLayout();" Single="True"></Show>
  8. #8
    Sorry, my bad. Try the following code:

    <ext:Panel runat="server" Border="false" Header="false" Layout="FormLayout">
    	<Items>
    		<ext:ColumnLayout runat="server" Split="false" FitHeight="true">
    			<Columns>
    				<ext:LayoutColumn ColumnWidth="0.25">
    					<ext:Panel runat="server" Html="<div style='font-weight:bold;font-size:9pt;margin:5px;margin-top:27px;'>Card 2:</div>" />
    				</ext:LayoutColumn>
    				<ext:LayoutColumn ColumnWidth="0.75">
    					<ext:Panel runat="server" Border="true" Frame="false" Layout="Form"
    						Padding="24">
    						<Items>
    							<ext:FileUploadField runat="server" AnchorHorizontal="100%" ID="FileUploadField1"
    								HideLabel="true">
    								<Listeners>
    									<Show Handler="this.syncSize();"></Show>
    								</Listeners>
    							</ext:FileUploadField>
    						</Items>
    					</ext:Panel>
    				</ext:LayoutColumn>
    			</Columns>
    		</ext:ColumnLayout>
    	</Items>
    	<Listeners>
    		<AfterRender Handler="this.setSize(this.ownerCt.layout.getLayoutTargetSize());
    						this.doLayout();" Delay="100" />
    		<Show Handler="this.doLayout(); FileUploadField1.syncSize();" Single="True"></Show>
    	</Listeners>
    </ext:Panel>
  9. #9
    Thanks Daulet! Your workaround seems to be working fine in my set-up. Please mark this thread as closed.

Similar Threads

  1. [CLOSED] layout issue when using RowLayout within column layout
    By Daly_AF in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 11, 2012, 2:40 PM
  2. [CLOSED] FileUploadField issue...
    By shahidmughal in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 29, 2010, 3:07 PM
  3. [CLOSED] CardLayout Active Index Layout Prob
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Jan 25, 2010, 4:28 PM
  4. CardLayout and combobox issue
    By fabiomarcos in forum 1.x Help
    Replies: 1
    Last Post: Mar 09, 2009, 8:17 AM
  5. [CLOSED] CardLayout rendering ALL panel contents at once AND OUTSIDE the CardLayout?
    By juanpablo.belli@huddle.com.ar in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 26, 2009, 3:08 PM

Tags for this Thread

Posting Permissions