[CLOSED] Looking for CompositeField

  1. #1

    [CLOSED] Looking for CompositeField

    I'm looking for somehting I call a CompositeField. Its like a MultiField in that it allows multiple inner fields to be grouped together with a common 'FieldLabel' so they are presented togther. However it differs from a MultiField in that allows you to define a layout for the inner-fields.

    Its derived from Field, and would have a FieldLabel value that a FormPanel would use to display a normal label, but rather than contain a row of one or more fields, it defines a multi-row layout of fields.

    Take the Address example, I want the FieldLabel="Address", but instead of one control for a value I want the first row to filled with a single TextField, the second row to have a seperate TextField for City, a ComboBox of states, and a TextField for zips with a zip validator.

    Is this clear what I'm looking for?
    Is it already doable?



  2. #2

    RE: [CLOSED] Looking for CompositeField

    Hi,

    You can use Panel and set IsFormField="true" in anchor. Also you should define own logic (or leave it empty) for function: reset, getName, validate

    <%@ Page Language="C#" %>
    
    <%@ Import Namespace="System.Collections.Generic" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" 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:ScriptManager ID="ScriptManager1" runat="server">
            </ext:ScriptManager>
       
            <ext:Panel runat="server" Width="400" Height="300">
                <Body>
                    <ext:FormLayout runat="server">
                        <ext:Anchor IsFormField="true">
                            <ext:Panel runat="server" FieldLabel="Panel" Border="false">
                                <Body>
                                    <ext:ContainerLayout runat="server">
                                        <ext:TextField runat="server" StyleSpec="display:block"></ext:TextField>
                                        <ext:TextField runat="server" StyleSpec="display:block"></ext:TextField>
                                        <ext:TextField runat="server" StyleSpec="display:block"></ext:TextField>
                                    </ext:ContainerLayout>
                                </Body>
                                
                                <CustomConfig>
                                    <ext:ConfigItem Name="reset" Value="Ext.emptyFn" Mode="Raw"></ext:ConfigItem>
                                    <ext:ConfigItem Name="getName" Value="Ext.emptyFn" Mode="Raw"></ext:ConfigItem>
                                    <ext:ConfigItem Name="validate" Value="function(){return true;}" Mode="Raw"></ext:ConfigItem>
                                </CustomConfig>
                            </ext:Panel>
                        </ext:Anchor>
                    </ext:FormLayout>
                </Body>
            </ext:Panel>
        </form>
    </body>
    </html>
  3. #3

    RE: [CLOSED] Looking for CompositeField

    Thanks, this looks good.

    What do I do in the reset &amp; getName functions? Is there example somewhere?
  4. #4

    RE: [CLOSED] Looking for CompositeField

    Hi,

    reset: Resets the current field value to the originally loaded value and clears any validation messages
    I think you need to call reset for all inner fields


    getName: Returns the name attribute of the field if available
    It uses by FormPanel to find field when record loads, you leave it as empty and FormPanel will use id instead name
  5. #5

    RE: [CLOSED] Looking for CompositeField

    Out of interests sake, here's how I would build the sample in v1.0 using an <ext:MultiField>.

    Example

    <ext:FormPanel 
        runat="server" 
        Title="Customer" 
        Width="350" 
        AutoHeight="true" 
        Frame="true">
        <Items>
            <ext:TextField runat="server" FieldLabel="Name" AnchorHorizontal="100%" />
            <ext:MultiField runat="server" FieldLabel="Address" AnchorHorizontal="100%">
                <Fields>
                    <ext:Container runat="server" Layout="Anchor">
                        <Defaults>
                            <ext:Parameter Name="Style" Value="margin-bottom:4px;" />
                            <ext:Parameter Name="Anchor" Value="100%" />
                        </Defaults>
                        <Items>
                            <ext:TextField runat="server" EmptyText="Address" />
                            <ext:TextField runat="server" EmptyText="City" />
                            <ext:ComboBox runat="server" EmptyText="State">
                                <Items>
                                    <ext:ListItem Text="Alabama" />
                                    <ext:ListItem Text="Alaska" />
                                    <ext:ListItem Text="Idaho" />
                                    <ext:ListItem Text="Texas" />
                                </Items>
                            </ext:ComboBox>
                            <ext:TextField runat="server" EmptyText="Zip" />
                        </Items>
                    </ext:Container>
                </Fields>
            </ext:MultiField>
        </Items>
    </ext:FormPanel>
    See screen capture attached.

    NOTE: the above code is using v1.0 syntax and may be subject to change before final release.

    Geoffrey McGill
    Founder
  6. #6

    RE: [CLOSED] Looking for CompositeField

    I like the new syntax for 1.0. Will make it a lot more streamline and a lot less clutter.

    Can't wait for v1.0.

Similar Threads

  1. [CLOSED] CompositeField LabelWidth
    By vadym.f in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 19, 2012, 12:55 PM
  2. [CLOSED] CompositeField: Second control always behind first.
    By ljcorreia in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Oct 28, 2011, 2:17 PM
  3. [CLOSED] CompositeField
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 28, 2011, 4:55 AM
  4. [CLOSED] CompositeField as ServerControl
    By Jean-Pierre Poulin in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 06, 2010, 3:24 AM
  5. [CLOSED] [1.0] CompositeField vs MultiField
    By r_honey in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 05, 2010, 3:50 PM

Posting Permissions