[CLOSED] How to access selected value of Dropdownfield which contains GridPanel Grouping values?

  1. #1

    [CLOSED] How to access selected value of Dropdownfield which contains GridPanel Grouping values?

    Hi,

    I have added Dropdownfield with GridPanel Grouping values in my project. I can get the details of selected value using directmethod, but I need to access the selected value of the dropdownfield from code behind to verify whether the value get selected or not. How can I access the selected value?
    Last edited by Daniil; Jan 10, 2012 at 7:37 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please look at the example.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        class Test
        {
            public string groupId { get; set; }
            public string test1 { get; set; }
            public string test2 { get; set; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new Test()
                    { 
                        groupId = "group1", 
                        test1 = "1", 
                        test2 = "1" 
                    },
                    new Test()
                    { 
                        groupId = "group1", 
                        test1 = "11", 
                        test2 = "11" 
                    },
                    new Test()
                    { 
                        groupId = "group1", 
                        test1 = "111", 
                        test2 = "111" 
                    },
                    new Test()
                    { 
                        groupId = "group2", 
                        test1 = "2", 
                        test2 = "2" 
                    },
                    new Test()
                    { 
                        groupId = "group2", 
                        test1 = "22", 
                        test2 = "22" 
                    },
                    new Test()
                    { 
                        groupId = "group2", 
                        test1 = "22", 
                        test2 = "22" 
                    },
                };
                store.DataBind();
            }
        }
    
        protected void GetValue(object sender, DirectEventArgs e)
        {
            Test test = JSON.Deserialize<Test>(this.DropDownField1.Text);
            if (test != null) 
            {
                X.Msg.Alert("test1", test.test1).Show();
            }
            else
            {
                X.Msg.Alert("No value", "No selected value.").Show();
            }
        }
    </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:DropDownField
                ID="DropDownField1"
                runat="server" 
                Editable="false" 
                Width="400" 
                TriggerIcon="SimpleArrowDown">
                <Component>
                    <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                        <Store>
                            <ext:Store runat="server" GroupField="groupId">
                                <Reader>
                                    <ext:JsonReader>
                                        <Fields>
                                            <ext:RecordField Name="groupId" />
                                            <ext:RecordField Name="test1" />
                                            <ext:RecordField Name="test2" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                        <ColumnModel runat="server">
                            <Columns>
                                <ext:Column Header="GroupId" DataIndex="groupId" />
                                <ext:Column Header="Test1" DataIndex="test1" />
                                <ext:Column Header="Test2" DataIndex="test2" />
                                <ext:CommandColumn>
                                    <Commands>
                                        <ext:GridCommand Icon="Accept" CommandName="Pick" />
                                    </Commands>
                                </ext:CommandColumn>
                            </Columns>
                        </ColumnModel>
                        <View>
                            <ext:GroupingView runat="server" />
                        </View>
                        <Listeners>
                            <Command Handler="this.dropDownField.setValue(Ext.encode(record.data));" />
                        </Listeners>
                    </ext:GridPanel>
                </Component>
            </ext:DropDownField>
            <ext:Button runat="server" Text="Get a test1" OnDirectClick="GetValue" />
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil,

    With the above example. Could you please advice how to set selected item with '111' after page load ?

    Thank you

Similar Threads

  1. Replies: 1
    Last Post: Jun 29, 2012, 11:51 AM
  2. [CLOSED] Access to selected gridpanel row data
    By HOWARDJ in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 11, 2011, 7:07 AM
  3. [CLOSED] Grouping by Description but needing access to an ID
    By rmelancon in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 09, 2010, 3:11 PM
  4. Recover values in selected items GridPanel
    By Dominik in forum 1.x Help
    Replies: 2
    Last Post: Jun 22, 2010, 8:19 AM
  5. Replies: 2
    Last Post: Jul 20, 2009, 1:10 PM

Tags for this Thread

Posting Permissions