[CLOSED] Get JSON Store Record from ComboBox on Select

  1. #1

    [CLOSED] Get JSON Store Record from ComboBox on Select

    I'm new to Ext.NET and I'm sure this has a simple solution but I've been googling for hours to no avail. This is what I need: when I select an item in my ComboBox, I want to retrieve the corresponding Store record as a JSON string. I'd prefer to do this in C# (code behind) not JavaScript, unless it's impossible or a js solution is much simpler.

    I set up my Store as follows:
    <ext:Store runat="server" ID="MuseumProjectStore" AutoDataBind="true">
                <ext:AjaxProxy Json="true" Url='<%#projectsUrl%>'>
                    <ActionMethods Read="POST" />
                        <ext:JsonReader Root="" />
                <ext:Model runat="server">
                        <ext:ModelField Name="PROJECT_ID" Type="Int" />
                        <ext:ModelField Name="PROJECT_NAME" Type="String" />
                        <ext:ModelField Name="PROJECT_DESC" Type="String" />
                        <ext:ModelField Name="PROJECT_STATUS_ID" Type="Int" />
                        <ext:ModelField Name="PROJECT_STATUS_DESC" Type="String" />
                        <ext:ModelField Name="REMEDIATION_ID" Type="Int" />
                        <ext:ModelField Name="REMEDIATION_DESC" Type="String" />
                        <ext:ModelField Name="REMEDIATION_DATE" Type="String" />
                        <ext:ModelField Name="CONTACT_ID" Type="Int" />
                        <ext:ModelField Name="CONTACT_DESC" Type="String" />
                        <ext:ModelField Name="SID" Type="String" />
    Here is the ComboBox (part of a FormPanel):
    <ext:ComboBox runat="server" ID="ProjectDropDown" FieldLabel="Project" DisplayField="PROJECT_NAME"
                                Editable="false" ValueField="PROJECT_ID" StoreID="MuseumProjectStore">
                                    <Select OnEvent="ProjectSelect">
                                        <EventMask ShowMask="true" />
    And here is the pathetic Select event handler:
    protected void ProjectSelect(object sender, DirectEventArgs e)
            int selectedIndex = ProjectDropDown.SelectedItem.Index;
            X.Msg.Alert("Alert", selectedIndex).Show();
    I tried accessing the Store record using the selected index but couldn't get it to work. :(

    Last edited by Baidaly; Jul 11, 2013 at 12:38 AM. Reason: [CLOSED]
  2. #2
    Hi @elisa,

    Welcome to the Ext.NET forums!

    A select record should be sent as an extra parameter.

    <%@ 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)
                Store store = this.ComboBox1.GetStore();
                store.DataSource = new object[] 
                    new object[] { "1", "Item 1" },
                    new object[] { "2", "Item 2" },
                    new object[] { "3", "Item 3" }
        protected void ComboBox1_Select(object sender, DirectEventArgs e)
            X.Msg.Alert("ComboBox1_Select", e.ExtraParams["record"]).Show();
    <!DOCTYPE html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
        <form runat="server">
            <ext:ResourceManager runat="server" />
                    <ext:Store runat="server">
                            <ext:Model runat="server">
                                    <ext:ModelField Name="value" />
                                    <ext:ModelField Name="text" />
                            <ext:ArrayReader />
                    <Select OnEvent="ComboBox1_Select">
                            <ext:Parameter Name="record" Value="records[0].data" Mode="Raw" Encode="true" />
  3. #3
    I knew it had to be that simple. Thank you so much!

Similar Threads

  1. Replies: 11
    Last Post: Jun 06, 2013, 1:14 PM
  2. [CLOSED] Can not select combobox items using store
    By blurken in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: May 21, 2012, 1:20 AM
  3. Can not select combobox items using store
    By blurken in forum 2.x Help
    Replies: 0
    Last Post: May 14, 2012, 1:23 AM
  4. Replies: 2
    Last Post: Jan 02, 2011, 3:06 PM
  5. How to select row by JSon...
    By rebulanyum in forum 1.x Help
    Replies: 0
    Last Post: Mar 03, 2010, 5:29 AM

Tags for this Thread

Posting Permissions