项目中一些基本的控件肯定是要掌握的啦,今天弄了个ExtJS3.0的ComboBox,虽然简单,但是也值得一写。

 

 
  
  1.            items: [{ 
  2.             xtype: 'combo'
  3.             fieldLabel: 'Customer Status'
  4.             id: 'customerStatus'
  5.             anchor: '95%',  
  6.             triggerAction: "all"
  7. mode: "local"
  8. displayField: "name"
  9. valueField: "name"
  10.             store: new Ext.data.ArrayStore({  
  11.      fields: ["name"], 
  12.             data: ['All''Active''Inactive'
  13.             }) 
  14.            }] 

 

这段代码出自于Ext.form.FormPanel的定义代码中,在FormPanel里面定义一个下拉框,里面的选项有All,Active,Inactive三个。

在官方的文档里面我们,可以看到一个实例化的过程。

 
  
  1. // create the combo instance 
  2. var combo = new Ext.form.ComboBox({ 
  3.     typeAhead: true
  4.     triggerAction: 'all'
  5.     lazyRender:true
  6.     mode: 'local'
  7.     store: new Ext.data.ArrayStore({ 
  8.         id: 0, 
  9.         fields: [ 
  10.             'myId'
  11.             'displayText' 
  12.         ], 
  13.         data: [[1, 'item1'], [2, 'item2']] 
  14.     }), 
  15.     valueField: 'myId'
  16.     displayField: 'displayText' 
  17. });