ExtJS:菜單ComboBox及串聯功能表應用

來源:互聯網
上載者:User

ExtJS:菜單ComboBox及串聯功能表應用

首頁一級菜單查詢分組,二級菜單查詢分組中的車輛資訊。

定義分組資料模型:

Ext.define('group',{extend:'Ext.data.Model',fields:[        {name:'groupid',mapping:'groupid',type:'int'},        {name:'groupname',mapping:'groupname',type:'string'}]});

定義分組groupStore:

var groupStore = Ext.create('Ext.data.Store', {model:'group',proxy : { type:'ajax',url : 'group/getgroup'  ,//請求urlreader : ({type:'json',totalProperty: "totalAllGroup",  //totalRecords屬性由json.results得到successProperty: true,    //json資料中,儲存是否返回成功的屬性名稱root: 'dataOfAllGroup'  ,        //構造中繼資料的數組由json.rows得到//idProperty : "id"       }),       autoLoad:true,    remoteSort:true}});groupStore.load();//載入資料

定義分組ComboBox

var groupCombo = Ext.create('Ext.form.ComboBox', {id : 'group',fieldLabel : '所屬部門',labelSeparator : ':',labelWidth: 80,triggerAction : 'all',store : groupStore,displayField : 'groupname',valueField : 'groupid',loadingText : '正在載入資料...',queryMode : 'local',forceSelection : true,value: '',typeAhead : true,width: 240,allowBlank:false,    margin: '3 5 3 10',    emptyText : '請選擇所屬部門',    listeners:{     //用於二級菜單,若是單菜單可注釋掉該監聽事件    select : function(combo, record,index){       Ext.getCmp('device').clearValue();//上級combo在select事件中清除下級的value    Ext.getCmp('device').getStore().load({    url: 'device/getdevice/' + combo.value,    });    }         }});

以上是單菜單的代碼,添加二級菜單,參考下面:

定義車輛資料模型:

Ext.define('model',{extend:'Ext.data.Model',fields:[        {name:'id',mapping:'id',type:'int'},        {name:'carno',mapping:'carno',type:'string'}]});

定義車輛deviceStore:

var deviceStore = Ext.create('Ext.data.Store', {model:'model',proxy : { type:'ajax',url : 'device/getdevice'  ,reader : ({type:'json',totalProperty: "totalAllDevice",  //totalRecords屬性由json.results得到successProperty: true,    //json資料中,儲存是否返回成功的屬性名稱root: 'dataOfAllDevice'  ,        //構造中繼資料的數組由json.rows得到//idProperty : "id"       }),}});

定義車輛ComboBox

var deviceCombo = Ext.create('Ext.form.ComboBox', {id : 'device',fieldLabel : '車牌號',labelSeparator : ':',labelWidth: 80,triggerAction : 'all',store : deviceStore,displayField : 'carno',valueField : 'carno',loadingText : '正在載入資料...',queryMode : 'local',forceSelection : true,value: '',typeAhead : true,width: 240,allowBlank:false,    margin: '3 5 3 10',    emptyText : '請選取查詢的車輛'});


重點在於:queryMode : 'local',如果不選擇從本地擷取資料來源,則會重新去遠程remote擷取。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.