//从webservice中取数据ajax
            Ext.Ajax.request({
                url: 'WebService.asmx/GetComboxFirst',
                method: 'POST',
                //jsonData: { UserName: "" },
                headers: { 'Content-Type': 'application/json;utf-8' },
                success: General,
                failure: On_Error
            });

function General(result) {
                var data = Ext.util.JSON.decode(result.responseText);
                var ds = new Ext.data.Store({
                    proxy: new Ext.data.MemoryProxy(data.d),
                    reader: new Ext.data.JsonReader({ fields: [{ name: 'strText', type: 'string' }, { name: 'strValue', type: 'string'}] })
                });

ds.load();
                var combox1 = new Ext.form.ComboBox({
                    store: ds,
                    displayField: 'strText',
                    valueField: 'strValue',
                    typeAhead: true,
                    mode: 'local',
                    forceSelection: true,
                    triggerAction: 'all',
                    emptyText: 'Select a state...',
                    selectOnFocus: true,
                    applyTo: 'combox1'
                });
                Genercombox2("1", 5);
                combox1.on('select', function (comboBox) {
                    //alert(comboBox.getRawValue() + '-' + comboBox.getValue());
                    Genercombox2("2", comboBox.getValue());
                });
            };

function On_Error() {
            };
            //从webservice中取数据ajax

//从webserivce中取通过HttpProxy,因为asp.net数据是放在.d里面的,所以需要重写JsonReader来取数据.

bJsonReader = Ext.extend(Ext.data.JsonReader, {
                read: function (response) {
                    var json = response.responseText;
                    //alert(json);
                    var o = Ext.decode(json);
                    //alert(o.d);
                    this.responseText = json;
                    if (!o) {
                        throw { message: 'JsonReader.read: Json object not found' };
                    }
                    return this.readRecords(o.d);
                }
            });
            var dshttpProxy = new Ext.data.Store({
                proxy: new Ext.data.HttpProxy({
                    url: "WebService.asmx/GetComboxFirstByParam", method: 'POST', jsonData: { strParam: 10 }
                }),
                reader: new bJsonReader({
                    fields: [{ name: 'strText', type: 'string' }, { name: 'strValue', type: 'string'}]
                })
            });

function Genercombox2(strtype, indexvalue) {

if (strtype == "1") {
                    var combox2 = new Ext.form.ComboBox({
                        store: dshttpProxy,
                        displayField: 'strText',
                        autoLoad: false,
                        valueField: 'strValue',
                        typeAhead: true,
                        mode: 'local',
                        id: 'gameAreaID',
                        forceSelection: true,
                        triggerAction: 'all',
                        emptyText: 'Select a state...',
                        loadingText: 'Please Select',
                        anchor: '100%',
                        selectOnFocus: true,
                        applyTo: 'combox2'
                    });
                }
                if (strtype == "2") {
                    var parent = Ext.getCmp('gameAreaID');
                    parent.reset();
                    //重新获取数据
                    dshttpProxy.proxy = new Ext.data.HttpProxy({
                        url: "WebService.asmx/GetComboxFirstByParam", method: 'POST', jsonData: { strParam: indexvalue }
                    });
                    dshttpProxy.load();
                }
            }
            //从webserivce中取通过HttpProxy

ComboBox联动 (AJAX BS实现)的更多相关文章

  1. vs2013+MVC3.0+EasyUI的ComboBox联动使用(二)

     vs2013+MVC3.0+EasyUI的ComboBox联动使用(二) 简单介绍:在vs2013(.net4.0)中使用MVC3.0对于EasyUI中ComboBox的联动使用. 载入Comb ...

  2. Extjs4 Combobox 联动始终出现loading错误的解决的方法

    当反复选者combobox 联动时,下级的Combobox 会出现loading的错误表现形式,尽管Store数据已载入完也是一样. 废话少说贴代码就知道怎样处理了:(注意红色部分的关键语句) }, ...

  3. Ext 4.2以后版本 ComboBox 联动

    //combox树 ComboTree: function (upDep, empStore) { var com = Ext.create('Ext.ux.desktop.ComboTree', { ...

  4. C# Combobox联动

    接上一篇博文,对界面做一个小修改,做4个combobox,形成窗口之间的联动: 界面如下: 选择combobox里的条件,单击查询获取数据 首先连接数据库,获取到数据到第一个combobox里,代码在 ...

  5. TopJUI Combobox 联动

    这里给联动进行一个简单定义:因Combobox选择或输入的值发生改变时对自身或者其它组件产生影响称为联动.(注:editable确定是否可以手动输入) 有两种实现方法: 一.自己写对应的onChang ...

  6. 练习: 省市联动(Ajax)

    // 示例一: china.xml (位于 src 目录下) <?xml version="1.0" encoding="utf-8"?> < ...

  7. JS 省市联动 ajax

    省市联动 //省市联动     $('.locationCode').change(function () {         var val = $(this).val();         if ...

  8. Extjs之combobox联动

    Ext.Loader.setConfig({ enabled : true }); Ext.Loader.setPath('Ext.ux', '../extjs/ux'); Ext.require([ ...

  9. jquery多级联动(ajax查数据库)

    /id 代表下级下拉框ID,cityCode代表的是父级菜单代码,所有级菜单在同一张表,后台在加载是把菜单已经加入到Map缓存中.... //id 代表下级下拉框ID,cityCode代表的是父级菜单 ...

随机推荐

  1. 有关 GCC 及 JNA 涉及动态库/共享库时处理库文件名的问题

    动态库尤其是共享库在 Linux 环境下普遍存在库文件名包含版本号的情况,比如 Linux 环境下经常会发现一个共享库的真实文件名是 libfoo.so.1.1.0,而同时会有多个指向该真实库文件的软 ...

  2. LucaCanali--SystemTap_Linux_IO

    https://github.com/LucaCanali/Linux_tracing_scripts/tree/master/SystemTap_Linux_IO

  3. HDU 1501

    Zipper Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  4. socket 网络编程高速入门(一)教你编写基于UDP/TCP的服务(client)通信

    由于UNIX和Win的socket大同小异,为了方便和大众化,这里先介绍Winsock编程. socket 网络编程的难点在入门的时候就是对基本函数的了解和使用,由于这些函数的结构往往比較复杂,參数大 ...

  5. XUtils BitmapUtils 改造以加入drawable支持

    === XUtilsBitmapUtils 改造以加入drawable支持 === # XUtils 简单介绍 XUtils 是一套少有的早期国产安卓框架, 其源于AFinal, 文件夹结构也与之相似 ...

  6. 【转载】轻松搞懂WebService工作原理

    用更简单的方式给大家谈谈WebService,让你更快更容易理解,希望对初学者有所帮助. WebService是基于网络的.分布式的模块化组件. 我们直接来看WebService的一个简易工作流程: ...

  7. mac系统下为emacs设置中文字体,解决乱码问题

    近期换了个系统,如今用mac系统. 当打开emacs后,中文支持的不是非常好.有的地方能显示.在.el文件的凝视里显示为口口口口口口口口这种框.例如以下图所看到的 找了半天.是由于中文字体的问题.仅仅 ...

  8. jk_proxy实现apache+tomcat负载均衡

    Apache + tomcat实现server集群 主要參照:http://blog.csdn.net/welun521/article/details/4169879 watermark/2/tex ...

  9. HDU 5371 Hotaru&#39;s problem(Manacher算法+贪心)

    manacher算法详见 http://blog.csdn.net/u014664226/article/details/47428293 题意:给一个序列,让求其最大子序列,这个子序列由三段组成, ...

  10. PostgreSQL 源码解读 node的模拟实现

      node的实现是PostgreSQL的查询解析的基础,实现的关键是两个宏,makeNode和newNode.其他节点继承自Node节点,如果增加新的结构体,需要添加NodeTag中添加对应的枚举值 ...