[CLOSED] DataIndex on DropDownField with a TreePanel

  1. #1

    [CLOSED] DataIndex on DropDownField with a TreePanel

    Hello?

    Since i couldnt make it work, I question? Does the dataindex works with a DropDownField containing a TreePanel (like: https://examples1.ext.net/#/Form/Dro...ield/Overview/ )

    Thanks
    Last edited by Daniil; Oct 24, 2011 at 6:10 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Why not, it works in the example below.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[] 
                    {
                        new object[] { "TextField", "DropDownField"}
                    };
                this.Store1.DataBind();
            }
        }
    </script>
    
    <!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 runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:FormPanel ID="FormPanel1" runat="server">
                <Items>
                    <ext:TextField runat="server" DataIndex="TextField" />
                    <ext:DropDownField runat="server" DataIndex="DropDownField">
                        <Component>
                            <ext:TreePanel runat="server">
                                <Root>
                                    <ext:TreeNode Text="Root" />
                                </Root>
                            </ext:TreePanel>
                        </Component>
                    </ext:DropDownField>
                </Items>
            </ext:FormPanel>
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="TextField" />
                            <ext:RecordField Name="DropDownField" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
            <ext:Button runat="server" Text="Load a record">
                <Listeners>
                    <Click Handler="FormPanel1.getForm().loadRecord(Store1.getAt(0));" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
  3. #3
    You, sir, are right!

    Case closed.
  4. #4
    Hi Danill

    This will not work if the dropdown has Mode="ValueText". Is there a way to use DataIndex still, or should one use dropdown.setValue(value, text, false) explicitly?
  5. #5
    Hi,

    In this case you should override the setValue method.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.Store1.DataSource = new object[] 
                    {
                        new object[] { "TextField", "DropDownField"}
                    };
                this.Store1.DataBind();
            }
        }
    </script>
     
    <!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 runat="server">
        <title>Ext.Net Example</title>
    
        <script type="text/javascript">
            var mySetValue = function (value, text, collapse) {
                if (this.mode === "text") {
                    collapse = text;
                    text = value;
                } else {
                    text = "some text based on the value: " + value;
                }
            
                Ext.net.DropDownField.superclass.setValue.apply(this, [text]);
                this.getUnderlyingValueField().setValue(value);
            
                if (!this.isExpanded()) {
                    this.syncValue(value, text);
                }
            
                if (collapse !== false) {
                    this.collapse();
                }
            
                return this;
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:FormPanel 
                ID="FormPanel1" 
                runat="server" 
                Width="300" 
                DefaultAnchor="100%" 
                HideLabels="true">
                <Items>
                    <ext:TextField runat="server" DataIndex="TextField" />
                    <ext:DropDownField 
                        runat="server" 
                        DataIndex="DropDownField" 
                        Mode="ValueText">
                        <Component>
                            <ext:TreePanel runat="server">
                                <Root>
                                    <ext:TreeNode Text="Root" />
                                </Root>
                            </ext:TreePanel>
                        </Component>
                        <Listeners>
                            <BeforeRender Handler="this.setValue = mySetValue.createDelegate(this);" />
                        </Listeners>
                    </ext:DropDownField>
                </Items>
            </ext:FormPanel>
            <ext:Store ID="Store1" runat="server">
                <Reader>
                    <ext:ArrayReader>
                        <Fields>
                            <ext:RecordField Name="TextField" />
                            <ext:RecordField Name="DropDownField" />
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
            <ext:Button runat="server" Text="Load a record">
                <Listeners>
                    <Click Handler="FormPanel1.getForm().loadRecord(Store1.getAt(0));" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 9
    Last Post: Jul 18, 2011, 7:55 AM
  2. [CLOSED] TreePanel in a DropDownField - SetValue
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 04, 2011, 2:12 PM
  3. [CLOSED] the dropdownfield with TreePanel don't display in ie7
    By lonely7345 in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 04, 2011, 3:04 AM
  4. Replies: 7
    Last Post: Nov 25, 2010, 5:18 PM
  5. [CLOSED] DropDownfield TreePanel Click Listener
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 26, 2009, 3:56 AM

Posting Permissions