ext 2.0 Combos 使用指南

 

这是个简单的例子,只需要简单的解释下,按步就班,从简单到复杂!

例子由两部分组成:lcombo.html 和 lcombo.js.

lcombo.html

  1. <!DOCTYPE HTML PUBLIC  "-//W3C//DTD HTML 4.01 Transitional//EN"    
  2.     "http://www.w3.org/TR/html4/loose.dtd" >  
  3. <html>  
  4. <head>  
  5.     <meta http-equiv="Content-Type"  content= "text/html; charset=utf-8" >  
  6.     <link rel="stylesheet"  type= "text/css"  href= "../extjs-2.0/resources/css/ext-all.css" >  
  7.     <script type="text/javascript"  src= "../extjs-2.0/adapter/ext/ext-base.js" ></script>  
  8.     <script type="text/javascript"  src= "../extjs-2.0/ext-all-debug.js" ></script>  
  9.     <script type="text/javascript"  src= "lcombo.js" ></script>  
  10.     <!-- A Localization Script File comes here -->  
  11.     <script type="text/javascript" >  
  12.         Ext.onReady(LCombo.app.init, LCombo.app);  
  13.     </script>  
  14.     <title>Linked Combos Example</title>  
  15. </head>  
  16. <body>  
  17. </body>  
  18. </html>  

这是ext运用的最小html!
不要忘记改变ext类库和资源的引用来部署你的ext!

lcombo.js

  1. /**  
  2.   * Ext 2.0 Linked Combos Tutorial  
  3.   * by Jozef Sakalos, aka Saki  
  4.   * extjs.com/learn/Tutorial:Linked_Combos_Tutorial_for_Ext_2  
  5.   */   
  6.    
  7. // reference local blank image   
  8. Ext.BLANK_IMAGE_URL = '../extjs-2.0/resources/images/default/s.gif' ;  
  9.    
  10. Ext.namespace('LCombo''LCombo.countries''LCombo.cities' );  
  11.    
  12. LCombo.countries = [  
  13.      ['USA''United States of America' ]  
  14.     ,['D''Germany' ]  
  15.     ,['F''France' ]  
  16.     ,['GB''Great Britain' ]  
  17. ];  
  18.    
  19. LCombo.cities = [  
  20.      [1, 'USA''New York' ]  
  21.     ,[2, 'USA''Cleveland' ]  
  22.     ,[3, 'USA''Austin' ]  
  23.     ,[4, 'USA''Los Angeles' ]  
  24.     ,[5, 'D''Berlin' ]  
  25.     ,[6, 'D''Bonn' ]  
  26.     ,[7, 'F''Paris' ]  
  27.     ,[8, 'F''Nice' ]  
  28.     ,[9, 'GB''London' ]  
  29.     ,[10, 'GB''Glasgow' ]  
  30.     ,[11, 'GB''Liverpool' ]  
  31. ];  
  32.    
  33. // create application   
  34. LCombo.app = function () {  
  35.     // do NOT access DOM from here; elements don't exist yet   
  36.    
  37.     // private variables   
  38.    
  39.     // private functions   
  40.    
  41.     // public space   
  42.     return  {  
  43.    
  44.         // public methods   
  45.         init: function () {  
  46.             var  form =  new  Ext.FormPanel({  
  47.                  renderTo:document.body  
  48.                 ,width: 400  
  49.                 ,height: 300  
  50.                 ,style:'margin:16px'   
  51.                 ,bodyStyle:'padding:10px'   
  52.                 ,title:'Linked Combos'   
  53.                 ,defaults: {xtype:'combo' }  
  54.                 ,items:[{  
  55.                      fieldLabel:'Select Country'   
  56.                     ,displayField:'country'   
  57.                     ,valueField:'cid'   
  58.                     ,store: new  Ext.data.SimpleStore({  
  59.                          fields:['cid''country' ]  
  60.                         ,data:LCombo.countries  
  61.                     })  
  62.                     ,triggerAction:'all'   
  63.                     ,mode:'local'   
  64.                     ,listeners:{select:{fn:function (combo, value) {  
  65.                         var  comboCity = Ext.getCmp( 'combo-city' );          
  66.                         comboCity.setValue('' );  
  67.                         comboCity.store.filter('cid' , combo.getValue());  
  68.                         }}  
  69.                     }  
  70.    
  71.                 },{  
  72.                      fieldLabel:'Select City'   
  73.                     ,displayField:'city'   
  74.                     ,valueField:'id'   
  75.                     ,id:'combo-city'   
  76.                     ,store: new  Ext.data.SimpleStore({  
  77.                          fields:['id''cid''city' ]  
  78.                         ,data:LCombo.cities  
  79.                     })  
  80.                     ,triggerAction:'all'   
  81.                     ,mode:'local'   
  82.                     ,lastQuery:''   
  83.                 }]  
  84.             });  
  85.         }  
  86.     };  
  87. }(); // end of app   
  88.    
  89. // end of file  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值