//从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. 更改navigationBar 颜色

    
 
 if (IS_IOS7()) { /* iOS7 时 Navigation 颜色 */ [[UINavigationBar appearance] setBarTintColor: HexCo ...

  2. jvisualvm远程监控 Visual GC plugin NOT supported for this JVM

    1. 找到jdk安装目录. 2. 进入jdk的 bin目录,新建文件jstatd.all.policy. 3.编辑jstatd.all.policy文件,内容如下: 4. 给jstatd.all.po ...

  3. mysql中进行删除操作时用到not in 导致删除不成功

    delete from tb_news where id not in ( select max(id) From tb_news Group By title ) 刚开始用这条语句删除一直不成功 然 ...

  4. android EditText监听和长度监测事件

    <?xml version="1.0" encoding="utf-8"?> <!-- 定义基础的LinearLayout布局 --> ...

  5. Tar压缩文件

    [root@test /root]# tar [-zxcvfpP] filename   [root@test /root]# tar -N 'yyyy/mm/dd' /path -zcvf targ ...

  6. 谷歌訪问之直接输入ip地址

    废话啥说.直接上IP: 173.194.121.51 173.194.43.19 173.194.65.147 74.125.235.148

  7. HashMap变成线程安全方法

    我们都知道.HashMap是非线程安全的(非同步的).那么怎么才能让HashMap变成线程安全的呢? 我认为主要可以通过以下三种方法来实现: 1.替换成Hashtable,Hashtable通过对整个 ...

  8. HDU 1040 As Easy As A+B [补]

    今天去老校区找她,不想带电脑了,所以没时间A题了 /*******************************************************************/ As Ea ...

  9. WebService Get/Post/Soap 方式请求

    import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.InputStream; im ...

  10. 下载Google官方/CM Android源码自己主动又一次開始的Shell脚本

    国内因为某种原因,下载CM或Google官方的Android源码总easy中断.总看着机器.一中断就又一次运行repo sync还太麻烦,所以我特意编写了一段shell脚本(download.sh). ...