PDA

View Full Version : [CLOSED] FieldDefaults inheritance



cwolcott
Sep 19, 2012, 9:23 PM
Below is a simple Window with FieldContainer(s). I was trying to understand how FieldDefaults are inherited. I would have assumed that the second FieldContainer would have inherited the FieldDefaults but it didn't. Is something wrong? If I uncomment the additional FieldDefaults in the 2nd container everything is displayed properly.

Based on Sencha Documentation for FieldContainer:


Like regular fields, FieldContainer can inherit its decoration configuration from the fieldDefaults of an enclosing FormPanel. In addition, FieldContainer itself can pass fieldDefaults to any fields it may itself contain.



<%@ 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>Field Default Samples</title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Window runat="server" Width="500" BodyPadding="5">
<Items>
<ext:FormPanel runat="server" Border="false">
<FieldDefaults LabelAlign="Right" LabelWidth="90" />
<Items>
<ext:FieldSet ID="FieldSet1" runat="server" Title="General" Collapsible="true" Collapsed="false">
<Items>
<ext:FieldContainer runat="server" FieldLabel="Name" Layout="HBoxLayout">
<FieldDefaults HideLabel="true" />
<Items>
<ext:TextField runat="server" EmptyText="First" Flex="1" FieldLabel="First Name" />
<ext:TextField runat="server" EmptyText="Last" Flex="2" FieldLabel="Last Name" />
</Items>
</ext:FieldContainer>
<ext:FieldContainer runat="server" Layout="HBoxLayout">
<%-- <FieldDefaults LabelAlign="Right" LabelWidth="90" />
--%>
<Items>
<ext:TextField runat="server" EmptyText="First" Flex="1" FieldLabel="First Name" />
<ext:TextField runat="server" EmptyText="Last" Flex="2" FieldLabel="Last Name" />
</Items>
</ext:FieldContainer>
<ext:TextArea runat="server" FieldLabel="Text Area" AnchorHorizontal="100%" />
</Items>
</ext:FieldSet>
</Items>
</ext:FormPanel>
</Items>
</ext:Window>
</body>
</html>

Daniil
Sep 20, 2012, 4:58 PM
Hi Chris,

The quote fro the docs means that FormPanel FieldDefaults affects on FieldContainer as well as it affects on common fields.

For example, FieldContainer LabelWidth will be 90 and it will be right aligned.

Example

<ext:FormPanel runat="server" Width="500">
<FieldDefaults LabelAlign="Right" LabelWidth="90" />
<Items>
<ext:FieldContainer runat="server" FieldLabel="Name" Layout="HBoxLayout" />
</Items>
</ext:FormPanel>

The second sentence means that FieldContainer supports the FieldDefaults setting for its items.

So, it doesn't mean that FieldContainer copies FieldDefaults of its container. But I agree it sounds a bit ambiguous.

You should apply the same FieldDefaults for FieldContainers if needed.

cwolcott
Sep 20, 2012, 5:29 PM
Got it. I understand now. I just wanted to make sure I wasn't over defining my sub-controls if it was suppose to inherit attributes. Please close the thread.