1. 程式人生 > >Ext.js二級聯動

Ext.js二級聯動

class combo tex 選擇 tps rec test back classic

<!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二級聯動