[CLOSED] Defaults cannot be overridden

  1. #1

    [CLOSED] Defaults cannot be overridden

    Sorry if the title isn't most accurate!

    Basically I am trying the following border layout with defaults for split and collapsible on most regions. Then on the center region, I explicitly set those values to false:

    <%@ Page Language="C#" %>
    <!DOCTYPE html>
    <html>
        <head>
            <title>Border Layout Example</title>
        </head>
        <body>
            <ext:ResourceManager runat="server" Theme="Gray" />
    
            <ext:Window runat="server" Layout="Border" Height="200" Width="400" Border="False">
                <Defaults>
                    <ext:Parameter Name="split" Value="true" />
                    <ext:Parameter Name="collapsible" Value="true" />
                </Defaults>
                <Items>
                    <ext:Panel region="West" runat="server" Title="West" Width="100" Weight="10" />
                    <ext:Panel region="Center" Split="False" Collapsible="False" Title="Center" runat="server" />
                    <ext:Panel region="South" runat="server" Title="South" Height="100" />
                </Items>
            </ext:Window>
        </body>
    </html>
    Notice the Center region will have a collapsible tool when it should not. Looking at the generated JavaScript the center region overrides are not being created:

    Ext.create("Ext.window.Window", {
        border: false,
        height: 200,
        hidden: false,
        renderTo: Ext.getBody(),
        width: 400,
        defaults: {
            "split": true,
            "collapsible": true
        },
        items: [{
            width: 100,
            region: "west",
            weight: 10,
            title: "West"
        }, {
            region: "center",
            title: "Center"
        }, {
            height: 100,
            region: "south",
            title: "South"
        }],
        layout: "border"
    });
    If I modify the JavaScript directly to add the split: true and collapsible: true to the center region and run it in firebug then it works as expected. If this is possible to fix, that would be great.

    Thanks!
    Last edited by Daniil; May 10, 2012 at 7:35 PM. Reason: [CLOSED]
  2. #2
    In markup you can use
    XCollapsible="False"
    X prefix for standard properties forces value rendering (even default)

    For code behind you have to use CustomConfig
  3. #3
    Vladimir, many thanks for such a swift response! Much appreciated.

    The suggestion works nicely. Using CustomConfig from code behind makes sense, as it is then just sent down as a regular custom property. I didn't realize the "X" trick via Markup. Neat trick!

    I also just checked, CustomConfig can also be used from markup:

    <ext:Panel region="Center" Title="Center" runat="server">
        <CustomConfig>
            <ext:ConfigItem Name="split" Value="false" Mode="Raw" />
            <ext:ConfigItem Name="collapsible" Value="false" Mode="Raw" />
        </CustomConfig>
    </ext:Panel>
    The above seems to work quite nicely too. "X" is probably a lot terser which is nice, and I will try to remember that, while the above is kind of symmetrical with the code-behind (by definition I guess!)

    Still the "X" for standard properties is nice. I will see if I can incorporate that into the book somehow...

    Thanks!
  4. #4
    In addition (though, I think, you know it) - declaring any non-existing properties in markup are considered as custom config options.

    Example
    <ext:Panel runat="server" MyProperty="Hello!">
    will produce
    {
        myProperty : 'Hello!' //with the lowercase first letter
    }
  5. #5
    Hey, I didn't know that... that's great! (Though unfortunately in my production code so much of it is typically done in code-behind - especially the parts where this could come in use! Anyway, good to know!)

Similar Threads

  1. Replies: 2
    Last Post: Jul 28, 2011, 5:08 PM
  2. [CLOSED] CustomConfig and Defaults
    By albayrak in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 18, 2011, 3:42 PM
  3. [CLOSED] Inconsistent column.sortable defaults.
    By randy85253 in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 30, 2010, 6:21 PM
  4. [CLOSED] formpanel defaults
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 08, 2009, 12:15 PM
  5. How to set Defaults value
    By lo230c in forum 1.x Help
    Replies: 5
    Last Post: Apr 02, 2009, 4:53 PM

Posting Permissions