2013-03-20 47 views
1

如何将我的selectfield的值正确传递到我店中的ajax代理?将视图中的selectfield中的值传递给商店

Ext.define('FirstApp.view.Home',{ 
extend:'Ext.Panel', 
xtype:'home', 
config:{ 
    title:'Home', 
    iconCls:'home', 
    html:'<h1>Home Page</h1><hr><p>Welcome to Sencha Touch 2 Training</p>', 
    layout:'fit', 
    scrollable:true, 
    styleHtmlContent:true, 
    styleHtmlCls:'home', 


    items: [ 
      { 
       xtype: 'selectfield', 
       id: 'visit', 
       label: 'Choose one', 
       value:'restaurant', 
       options: [ 
        {text: 'Museum', value: 'museum'}, 
        {text: 'Pubs', value: 'pub'}, 
        {text: 'Attractions', value: 'attraction'} 
       ] 
      } 
     ] 
       } 

    }) 

我想把值放在这里:'+ REFERENCE HERE +'在下面的代码中。我曾尝试“+#访问+”和“+#+价值”,但没有成功

Ext.define('FirstApp.store.Places',{ 
extend:'Ext.data.Store', 

config:{ 

    autoLoad:true, 
    model:'FirstApp.model.Place', 
    proxy:{ 
     type:'ajax', 
     url:'https://maps.googleapis.com/maps/api/place/search/json? location=52.247983,-7.141113&radius=10000&types=food&name='+ REFERENCE HERE +'&sensor=false&key=KEY', 
     reader:{ 
      type:'json', 
      rootProperty:'results' 
     } 
    } 
} 
}) 

回答

0

要您要使用Ext.getCmp,然后用getValue方法煎茶框架通过ID得到一个组件。所以,你在哪里试图把基准,把这个:

Ext.getCmp('visit').getValue() 

最好要尽量远离硬编码的组件ID而去,而是使用基于组件路径,类型等

裁判/选择器
+0

我试过'+ Ext.getCmp('visit')。getValue()+'从这里我得到下面的错误。 Uncaught TypeError:无法调用未定义的方法getValue – paulpwr 2013-03-21 11:26:31

相关问题