View Full Version : [CLOSED] Defaults cannot be overridden

May 10, 2012, 6:37 PM
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>
<title>Border Layout Example</title>
<ext:ResourceManager runat="server" Theme="Gray" />

<ext:Window runat="server" Layout="Border" Height="200" Width="400" Border="False">
<ext:Parameter Name="split" Value="true" />
<ext:Parameter Name="collapsible" Value="true" />
<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" />

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.


May 10, 2012, 7:11 PM
In markup you can use


X prefix for standard properties forces value rendering (even default)

For code behind you have to use CustomConfig

May 10, 2012, 7:28 PM
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">
<ext:ConfigItem Name="split" Value="false" Mode="Raw" />
<ext:ConfigItem Name="collapsible" Value="false" Mode="Raw" />

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...


May 10, 2012, 7:35 PM
In addition (though, I think, you know it) - declaring any non-existing properties in markup are considered as custom config options.


<ext:Panel runat="server" MyProperty="Hello!">
will produce

myProperty : 'Hello!' //with the lowercase first letter

May 11, 2012, 9:27 AM
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!)