[CLOSED] How to make server control with 2 DateField inside(display issue) showing only 1 DateField

  1. #1

    [CLOSED] How to make server control with 2 DateField inside(display issue) showing only 1 DateField

    Hi,

    I'm trying to make server control which will contains 2 DateField inside of it.
    But only 1 DateField is display for now.
    Here's sample:
    aspx
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net, Version=1.5.0.0, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87" %>
    <%@ Register TagPrefix="uc" Namespace="Ext1._6Test.controls" Assembly="Ext1.6Test" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
    
    }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Test</title>
    </head>
    <body>
        <ext:ResourceManager runat="server"/>
        <ext:Viewport runat="server">
            <Items>
                <ext:Panel runat="server" Layout="Fit">
                    <Items>
                        <ext:NumberField runat="server" ID="number" FieldLabel="Number"></ext:NumberField>
                        <ext:ComboBox runat="server" ID="combo" FieldLabel="Combo"></ext:ComboBox>
                        <uc:FromToControl runat="server" ID="fromTo"/>
                    </Items>
                </ext:Panel>
            </Items>
        </ext:Viewport>
    </body>
    </html>
    Control
    public class FromToControl : Ext.Net.CompositeField
        {
            private Ext.Net.DateField DateField1;
            private Ext.Net.DateField DateField2;
    
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
                DateField1 = new Ext.Net.DateField() { ID = this.ID + "datefield1", Flex = 1, Vtype = "daterange", Cls = "searchDatePickerLeft", CtCls = "searchDatePicker", Format = "dd-MM-yyyy" };
                Ext.Net.ConfigItem configItem1 = new ConfigItem("endDateField", "DateField2", ParameterMode.Value);
                DateField1.CustomConfig.Add(configItem1);
                DateField1.Listeners.AfterRender.Handler = "this.label.addClass('searchLabel');";
                DateField2 = new Ext.Net.DateField() { ID = this.ID + "datefield2", Flex = 2, Cls = "searchDatePickerLeft", CtCls = "searchDatePicker", Vtype = "daterange", Format = "dd-MM-yyyy", FieldLabel = "From" };
                Ext.Net.ConfigItem configItem2 = new ConfigItem("startDateField", "DateField1", ParameterMode.Value);
                DateField2.CustomConfig.Add(configItem2);
                this.LayoutConfig.Align = HBoxAlign.Middle;
                this.Items.Add(DateField1);
                this.Items.Add(DateField2);
            }
        }
    how should I do to make it work properly? I need to display 2 DatePicker inline. It's for advance search feature.

    Thanks,
    ViDom
    Last edited by Daniil; Jan 09, 2013 at 4:53 PM. Reason: [CLOSED]
  2. #2
    Hi @ViDom,

    A JavaScript errors occurs "this.label is undefined".

    It is here:
    DateField1.Listeners.AfterRender.Handler = "this.label.addClass('searchLabel');";
    It breaks rendering.

    Also the FitLayout supports a single item only.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @ViDom,

    A JavaScript errors occurs "this.label is undefined".

    It is here:
    DateField1.Listeners.AfterRender.Handler = "this.label.addClass('searchLabel');";
    It breaks rendering.

    Also the FitLayout supports a single item only.
    I've forgot about check javascript error:(
    So how can I add extra class to LabelField in DateField?
  4. #4
    I can't see the FieldLabel of the DateField1 in your example.

    Also I would use FieldLabel in the FormLayout context only.

    In your case I would use common DisplayFields to organize labels before the DateFields.
  5. #5
    Quote Originally Posted by Daniil View Post
    I can't see the FieldLabel of the DateField1 in your example.

    Also I would use FieldLabel in the FormLayout context only.

    In your case I would use common DisplayFields to organize labels before the DateFields.
    common DisplayFields what is that?

    CompositeField has FormLayout? I was thinking that there is in default HBoXLayout am I wrong?
  6. #6
    Quote Originally Posted by ViDom View Post
    common DisplayFields what is that?
    It is an <ext:DisplayField> control.

    Quote Originally Posted by ViDom View Post
    CompositeField has FormLayout? I was thinking that there is in default HBoXLayout am I wrong?
    Yes, there is HBoxLayout. It is why I suggested to don't use FieldLabels within a CompositeField.
  7. #7
    Quote Originally Posted by Daniil View Post
    It is an <ext:DisplayField> control.



    Yes, there is HBoxLayout. It is why I suggested to don't use FieldLabels within a CompositeField.
    could you please provide some sample of using it and configuring? I couldn't find this is examples:(

    When I changed inheritance from CompositeField to DisplayField there is a lot of errors. Display field doesn't contain Items collection so for what it is?;>

    Ok. I was able to make it right by adding cssClass to one of my DateField control like this:

    DateField2.Listeners.AfterRender.Handler = "this.el.parent().addClass('myClass');";
    Thread can be closed:)

    Thanks @Daniil your support were very helpful :)
    Last edited by ViDom; Jan 10, 2013 at 1:59 PM.

Similar Threads

  1. [FIXED] [1.2] DateField Display Problem
    By sky73rx3 in forum Bugs
    Replies: 5
    Last Post: Nov 17, 2011, 1:27 PM
  2. DateField display error in explorer 9
    By Fabrizio in forum 1.x Help
    Replies: 2
    Last Post: Jun 05, 2011, 6:00 PM
  3. Replies: 11
    Last Post: Apr 08, 2010, 2:36 PM
  4. Replies: 7
    Last Post: Aug 12, 2009, 5:04 PM
  5. Hotkey to display DateField's Calendar
    By leonardobag in forum Examples and Extras
    Replies: 0
    Last Post: Jul 03, 2009, 12:28 PM

Tags for this Thread

Posting Permissions