zoukankan      html  css  js  c++  java
  • ComboBox联动 (AJAX BS实现)

      //从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

  • 相关阅读:
    微服务 面试
    SpringMVC工作原理
    win7系统不能用telnet命令的两种解决方法
    Java NIO框架Netty教程(一) – Hello Netty
    基于JT/T808协议的车辆监控平台架构方案
    分布式高并发物联网(车联网-JT808协议)平台架构方案
    Linux CGroup
    Linux top、VIRT、RES、SHR、SWAP(S)、DATA Memory Parameters Detailed
    UEFI BIOS Rootkit Analysis
    Kademlia、DHT、KRPC、BitTorrent 协议、DHT Sniffer
  • 原文地址:https://www.cnblogs.com/meimao5211/p/3429615.html
Copyright © 2011-2022 走看看