首页 > Web开发 > 详细

Ext.js二级联动

时间:2019-04-25 10:09:43      阅读:159      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html>
   <head>
           <meta charset="utf-8">
      <link href="https://cdn.bootcss.com/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet">
   <script src="https://cdn.bootcss.com/extjs/6.0.0/ext-all.js"></script>
   <script type="text/javascript">
    var attr_city = ["嘉峪关","金昌"];
    var attr_county = [
                    [嘉峪关],
                    [河西堡,永昌县,金昌区]
                ];
   
 Ext.onReady(function () {    
            //定义新的类FormPanel,并且把变化的属性暴露出来以便以后继承
            var MyFormPanel = Ext.extend(Ext.form.FormPanel, {
                title: 级联,
               layout : table,
                layoutConfig : {columns:8},
                labelWidth: 80,
                initComponent: function () {
                    this.items = [
                    {
         fieldLabel : ,
         hiddenName : tmember.addressProvince,
         xtype : combo,
         allowBlank : false,
         width:180,
         labelWidth:20,
         emptyText : 请选择市,
         mode : local,
         displayField : provinceName,
         valueField : id,
         id : city,
         editable : false,
         triggerAction : all,
         lazyInit : false,
         store :attr_city,
         listeners:{
           select : function(combo, record, index){
           console.log(attr_county[record.internalId-1])
           var fieldName=Ext.getCmp(county);
           console.dir(fieldName)
           Ext.getCmp(county).setValue(attr_county[record.internalId-1][0]);
           Ext.getCmp(county).setStore(attr_county[record.internalId-1]);

           }
       }
               },
          {
        fieldLabel : ,
        labelWidth:20,
         hiddenName : county,
         xtype : combo,
         width:180,
         allowBlank : false,
         emptyText : 请选择县,
         mode : local,
         displayField : county,
         valueField : county,
         id : county,
         editable : false,
         triggerAction : all,
         lazyInit : false,
         store:‘‘
               },
                       
          {
          fieldLabel : 地址,
          labelWidth:40,
          id:county1,
          xtype : textfield,
          grow : false,
          colspan : 8
            }
                    ];
                    this.buttons = [{
                        text: 确 定,
                        handler: this.submit,//变化的部份
                        scope: this
                    }, {
                        text: 取 消,
                        handler: this.cancel,//变化的部份
                        scope: this
                    }];
                    MyFormPanel.superclass.initComponent.call(this, arguments); //调用父类的initComponent
                }
            });
           
            //创建测试对象2
            var testForm2=new MyFormPanel({
                title: 覆盖属性,
                usernameid:usernameid,
                submit: function () {
                    alert(this.usernameid);
                },
                cancel: function () {
                    testForm2.getForm().reset();
                }
            });
            //创建窗体
            var win = new Ext.Window({
                title: 窗口,
                id: window,
                width: 700,
                height: 420,
                resizable: true,
                closable: true,
                maximizable: true,
                minimizable: true,
                items: [testForm2]
            });
            win.show();
        });
      </script>
   </head>
   <body>
   </body>
</html>

 

Ext.js二级联动

原文:https://www.cnblogs.com/feifeicui/p/10766546.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!