[CLOSED] MaxWidth on a Field or FormPanel

  1. #1

    [CLOSED] MaxWidth on a Field or FormPanel



    How can I set a MaxWidth for a Field or a FormPanel? All of the examples I can find are only for setting the MaxWidth of a BorderLayout.Region. I also found this old unanswer post on the issue:

    http://forums.ext.net/showthread.php...light=MaxWidth

    I want to set AnchorHorizonal and MaxWidth on a field, so that it expands to full width, up to the MaxWidth.
  2. #2

    RE: [CLOSED] MaxWidth on a Field or FormPanel

    Hi,

    MaxWidth is used by container if this one is border layout region.
    You can add own logic. Please see the following sample
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!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></title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            <ext:Window runat="server" Width="300" Height="200" Layout="Form">
                <Items>
                    <ext:TextField runat="server" AnchorHorizontal="100%" MaxWidth="250">
                    </ext:TextField>
                    
                    <ext:TextField runat="server" AnchorHorizontal="100%" MaxWidth="500">
                    </ext:TextField>
                </Items>
                <Listeners>
                    <AfterLayout Handler="this.items.each(function(item){var width = Math.min(item.getWidth(), item.maxWidth); item.setWidth(width); item.setValue(width);});" />
                </Listeners>
            </ext:Window>
        </form>
    </body>
    </html>
  3. #3

    RE: [CLOSED] MaxWidth on a Field or FormPanel

    Hi,

    There is better solution


    Geoffrey said that ExtJS 3.0 has the following properties which automatic constrain the size


    boxMaxHeight : Number<div class="mdesc" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 0px; color: rgb(68, 68, 68); "><div class="long" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: 18px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The maximum value in pixels which this BoxComponent will set its height to.</p>

    Warning: This will override any size management applied by layout managers.


    boxMaxWidth : Number<div class="mdesc" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 0px; color: rgb(68, 68, 68); "><div class="long" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: 18px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The maximum value in pixels which this BoxComponent will set its width to.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Warning: This will override any size management applied by layout managers.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
    </p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">boxMinHeight : Number</p><div class="mdesc" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 0px; color: rgb(68, 68, 68); "><div class="long" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: 18px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The minimum value in pixels which this BoxComponent will set its height to.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Warning: This will override any size management applied by layout managers.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
    </p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">boxMinWidth : Number</p><div class="mdesc" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 5px; padding-right: 0px; padding-bottom: 5px; padding-left: 0px; color: rgb(68, 68, 68); "><div class="long" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; display: block; line-height: 18px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">The minimum value in pixels which this BoxComponent will set its width to.</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">Warning: This will override any size management applied by layout managers.</p>



    </p>



    </p>


  4. #4

    RE: [CLOSED] MaxWidth on a Field or FormPanel

    Here's a quick sample to demonstrate .BoxMaxWidth property on the fields.

    Example

    <ext:Window 
        ID="Window1" 
        runat="server" 
        Title="Example" 
        Padding="5"
        Height="185" 
        Width="350" 
        Layout="form" 
        DefaultAnchor="100%">
        <Items>
            <ext:TextField runat="server" FieldLabel="Name" BoxMaxWidth="350" />
            <ext:DateField runat="server" FieldLabel="Birth" BoxMaxWidth="350" />
        </Items>
    </ext:Window>
    The property could also be set in the <Defaults> to apply to all child items.

    Hope this helps.

    Geoffrey McGill
    Founder
  5. #5

    RE: [CLOSED] MaxWidth on a Field or FormPanel



    OK, I'll play with these. Thanks.

    So I assume from these two posts that MaxWidth of a BoxComponent does not render as boxMaxWidth in ExtJs ???
  6. #6

    RE: [CLOSED] MaxWidth on a Field or FormPanel

    Yes, there is a problem with the .MaxWidth/.MinWidth/.MaxHeight/.MinHeight properties in BoxComponentBase.cs.

    I think we're going to have to rename those properties to .BoxMaxWidth and add a new "Region" property for each, such as .RegionMaxWidth.


    This will cause a breaking change.


    Geoffrey McGill
    Founder
  7. #7

    RE: [CLOSED] MaxWidth on a Field or FormPanel

    ok, I made some changes to the underlying logic of the .MaxWidth and .BoxMaxWidth properties (+related min or height properties) that should help clean things up *without* causing a Breaking Change.

    The .MaxWidth property will remain, although setting the .MaxWidth property will now directly set .BoxMaxWidth instead of rendering as .maxWidth. Previously the .MaxWidth property rendered as .maxWidth in the client config. Now it will render as .boxMaxWidth.

    The .maxWidth config was only relevant if the Component was rendered into a BorderLayout region. If you absolutely must render the .maxWidth config item, you can do so by setting either the new .RegionMaxWidth property on any BoxComponent or the existing .MaxWidth property on the BorderLayout Region config.

    If Split="true" on the Region, the region will not expand beyond the .BoxMaxWidth or .MaxWidth, or .RegionMaxWidth.

    If both .BoxMaxWidth and .RegionMaxWidth are set on a Panel, the .RegionMaxWidth property will take precedence and .BoxMaxWidth will be ignored.

    The following sample demonstrates setting the .MaxWidth property on the <West> Region config.

    Example #1

    <ext:Viewport runat="server" Layout="border">
        <Items>
            <ext:BorderLayout runat="server">
                <West Split="true" MaxWidth="250">
                    <ext:Panel runat="server" Title="West" Width="200" />
                </West>
                <Center>
                    <ext:Panel runat="server" Title="Center" />
                </Center>
            </ext:BorderLayout>
        </Items>
    </ext:Viewport>
    The following sample demonstrates setting the .RegionMaxWidth property on the <West> Region config, which will render with the same results as Example #1.

    Example #2

    <West Split="true">
        <ext:Panel runat="server" Title="West" Width="200" RegionMaxWidth="250" />
    </West>
    The following two samples demonstrate the .BoxMaxWidth and .MaxWidth properties on any BoxComponent (Panel). Both will render a .boxMaxWidth config item to the client configuration script. Both will result in the same functionality as the first two examples.

    Example #3

    // BoxMaxWidth
    <West Split="true">
        <ext:Panel runat="server" Title="West" Width="200" BoxMaxWidth="250" />
    </West>
    
    // MaxWidth
    <West Split="true">
        <ext:Panel runat="server" Title="West" Width="200" MaxWidth="250" />
    </West>
    The following samples demonstrate a Viewport configuration by setting the .Region and .Split properties on the inner Panel <Items>, without the need for the wrapping <West> Region config or <ext:BorderLayout>

    Example #4

    <ext:Viewport runat="server" Layout="border">
        <Items>
            <ext:Panel runat="server" Title="West" Width="200" Region="West" MaxWidth="250" />
            <ext:Panel runat="server" Title="Center" />
        </Items>
    </ext:Viewport>
    What technique would I recommend for configuring a Viewport? Answer, Example #4.

    The above changes are backwards compatible, so this should not result in any breaking changes.

    Hope this helps.

    Geoffrey McGill
    Founder

Similar Threads

  1. [CLOSED] Ext.Msg.show maxWidth config
    By softmachine2011 in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Sep 21, 2012, 10:56 AM
  2. Replies: 7
    Last Post: Feb 27, 2012, 11:04 AM
  3. Replies: 32
    Last Post: Nov 17, 2010, 12:08 PM
  4. [CLOSED] Anchor MaxWidth
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 08, 2010, 9:40 AM
  5. [CLOSED] FormPanel required field
    By turione in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Aug 20, 2009, 2:33 PM

Posting Permissions