[CLOSED] ComboBox and HttpProxy

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] ComboBox and HttpProxy

    Hello,

    If you could run the following example:

    Example.aspx:
    <%@ Page Language="C#" %>
    <%@ 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">
    <script runat="server">
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
    
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager runat="server" EnablePartialRendering="True" />
            <ext:ScriptManager runat="server" StateProvider="PostBack" />
    
            <ext:ComboBox ID="drpCountry"
                runat="server"
                Width="255">
                <Items>
                    <ext:ListItem Text="Canada" Value="1" />
                    <ext:ListItem Text="United Kingdom" Value="2" />
                    <ext:ListItem Text="United States" Value="3" />
                </Items>
                <Listeners>
                    <Select Handler="#{Provinces}.reload();" />
                </Listeners>
            </ext:ComboBox>
            <ext:Store ID="Provinces"
                runat="server"
                AutoLoad="True">
                <Proxy>
                    <ext:HttpProxy Url="Example-Province.ashx" />
                </Proxy>
                <Reader>
                    <ext:JsonReader Root="Province">
                        <Fields>
                            <ext:RecordField Name="Text" />
                            <ext:RecordField Name="Value" DefaultValue="" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
                <BaseParams>
                    <ext:Parameter Name="CountryId" Value="#{drpCountry}.getValue()" Mode="Raw" />
                </BaseParams>
                <SortInfo Field="Text" Direction="ASC" />
            </ext:Store>
            <ExtJS:ComboBox ID="drpProvince"
                runat="server"
                StoreID="Provinces"
                DisplayField="Text"
                Editable="True"
                EmptyText="----"
                ForceSelection="True"
                Mode="Local"
                Select&#111;nfocus="True"
                TriggerAction="All"
                TypeAhead="True"
                ValueField="Value"
                Width="255">
                <Listeners>
                    <Select Handler="#{Cities}.reload();" />
                </Listeners>    
            </ExtJS:ComboBox>
            <ext:Store ID="Cities"
                runat="server"
                AutoLoad="True">
                <Proxy>
                    <ext:HttpProxy Url="Example-City.ashx" />
                </Proxy>
                <Reader>
                    <ext:JsonReader Root="City">
                        <Fields>
                            <ext:RecordField Name="Text" />
                            <ext:RecordField Name="Value" DefaultValue="" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
                <BaseParams>
                    <ext:Parameter Name="ProvinceId" Value="#{drpProvince}.getValue()" Mode="Raw" />
                </BaseParams>
                <SortInfo Field="Text" Direction="ASC" />
            </ext:Store>
            <ExtJS:ComboBox ID="drpCity"
                runat="server"
                StoreID="Cities"
                DisplayField="Text"
                Editable="True"
                EmptyText="----"
                ForceSelection="True"
                Mode="Local"
                Select&#111;nfocus="True"
                TriggerAction="All"
                TypeAhead="True"
                ValueField="Value"
                Width="255" />
    
            <ext:Button ID="btnSubmit" runat="server" AutoPostBack="True" &#111;nclick="btnSubmit_Click" Text="Submit" />
    
        </form>
    </body>
    </html>
    Example-Province.ashx:
    <%@ WebHandler Language="C#" Class="Example_Handler" %>
    
    using System;
    using System.Collections.Generic;
    using System.Web;
    using Coolite.Ext.Web;
    
    public class Example_Handler : IHttpHandler
    {
        public void ProcessRequest (HttpContext Context)
        {
            if (!String.IsNullOrEmpty(Context.Request["CountryId"]))
            {
                IList<Dictionary<string, string>> result = new List<Dictionary<string, string>>();
    
                Dictionary<string, string> item1 = new Dictionary<string, string>();
    
                item1.Add("Text", "Ontario");
                item1.Add("Value", "ON");
    
                Dictionary<string, string> item2 = new Dictionary<string, string>();
    
                item2.Add("Text", "Quebec");
                item2.Add("Value", "QC");
    
                result.Add(item1);
                result.Add(item2);
    
                Context.Response.ContentType = "text/json";
    
                Context.Response.Write(String.Format("{{ 'Province' : {0} }}", JSON.Serialize(result)));
            }
        }
     
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
    Example-City.ashx:
    <%@ WebHandler Language="C#" Class="Example_Handler" %>
    
    using System;
    using System.Collections.Generic;
    using System.Web;
    using Coolite.Ext.Web;
    
    public class Example_Handler : IHttpHandler
    {
        public void ProcessRequest (HttpContext Context)
        {
            if (!String.IsNullOrEmpty(Context.Request["ProvinceId"]))
            {
                IList<Dictionary<string, string>> result = new List<Dictionary<string, string>>();
    
                Dictionary<string, string> item1 = new Dictionary<string, string>();
    
                item1.Add("Text", "Toronto");
                item1.Add("Value", "TO");
    
                Dictionary<string, string> item2 = new Dictionary<string, string>();
    
                item2.Add("Text", "Ottawa");
                item2.Add("Value", "OT");
    
                result.Add(item1);
                result.Add(item2);
    
                Context.Response.ContentType = "text/json";
    
                Context.Response.Write(String.Format("{{ 'City' : {0} }}", JSON.Serialize(result)));
            }
        }
     
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
    Replication steps:

    1. Load page
    2. Select "Canada" from first ComboBox
    3. Select "Ontario" from second ComboBox
    4. Select "Toronto" from forth ComboBox
    5. Hit submit

    Notice it loaded Canada, and Ontario. How can I make it reload the Toronto?

    Need help as soon as possible! :)

    Cheers,
    Timothy
  2. #2

    RE: [CLOSED] ComboBox and HttpProxy

    Hi Timothy,

    please add next listener to Province (second) store

                <Listeners>
                    <Load Handler="#{Cities}.reload();" Single="true" Delay="100" />
                </Listeners>
    It is not ideal, not so good solution but you want a quick answer :)

  3. #3

    RE: [CLOSED] ComboBox and HttpProxy

    Very nasty indeed :)
  4. #4

    RE: [CLOSED] ComboBox and HttpProxy

    Timothy (10/1/2008)Very nasty indeed :)
    Oh, is this a bug or me not using the ComboBox properly?
  5. #5

    RE: [CLOSED] ComboBox and HttpProxy

    The reason why the value for third combo does not reloaded after postback: we use setValue for set combo value after postback. But in ExtJS the setValue does not fire Select event (Select event fired only if user manually select value).

    You can ask why second combo reloaded. Because for first combo you use inline items and first combo with values on page load. The second store have AutoLoad property (after page load it auto load own values and using value in BaseParams from first combo which is with values)


  6. #6

    RE: [CLOSED] ComboBox and HttpProxy

    OK, fair enough. So this is a design problem on my behalf, can you please provide me with a proper solution to achieve the following? I would like to know how to do it the proper way :)

    Cheers,
    Timothy
  7. #7

    RE: [CLOSED] ComboBox and HttpProxy

    hmmm... good question Timothy.

    I think the good solution would be if setValue will be fire select event. But for it need to change js code of Ext.form.ComboBox

    For example we can add bool property to Coolite combo - SelectEventOnSetValue (or other name) and if this property set then fire select event in js code in setValue function

  8. #8

    RE: [CLOSED] ComboBox and HttpProxy

    If you could add it and it wouldn't cause any trouble, I would be extremely greatful :)

    Of course, I will leave that decision to you.
  9. #9

    RE: [CLOSED] ComboBox and HttpProxy

    Timothy (10/1/2008)If you could add it and it wouldn't cause any trouble, I would be extremely greatful :)

    Of course, I will leave that decision to you.
    You guys think this is something that can be implemented easily? I would like to use my original example in numerous places, but I don't think that original suggestion (work-around) is working properly in all scenarios :s

    Cheers,
    Timothy
  10. #10

    RE: [CLOSED] ComboBox and HttpProxy

    Hi Timothy,

    I'll try to implement and check this solution today/tomorrow. I let you know about results soon

Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] XmlDataSource without URL / HttpProxy
    By ecko in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 13, 2012, 2:54 PM
  2. set text value in combobox via httpproxy
    By Birgit in forum 1.x Help
    Replies: 7
    Last Post: May 19, 2011, 10:48 AM
  3. HttpProxy and JsonReader
    By santosbj in forum 1.x Help
    Replies: 1
    Last Post: Jun 18, 2010, 5:29 AM
  4. [CLOSED] [1.0] HttpProxy and Parameters
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Feb 11, 2010, 6:01 PM
  5. [CLOSED] HttpProxy
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Oct 08, 2008, 11:09 AM

Posting Permissions