`

Ext combox从后台取值

阅读更多
var RecordDef = Ext.data.Record.create([
      {
       name: 'id'
      },{
       name:'name'
      }              
 ]);
var cityStore = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'comboxdata.php'}),
//代理方式
reader:new Ext.data.JsonReader({//解析器
   id:"id",//主键
   totalProperty:"restults",//条数
   root:"row"//结果集
   },RecordDef),
   listeners :{
     load : function(){
     }},
   remoteStore:true//排序
 });
 cityStore.load();
var combo = new Ext.form.ComboBox({
   store:cityStore,//数据源
   emptyText:'选择一个城市',
   loadingText:'loading',
   selectOnFocus:true,
   displayField:'name',
   mode:'remote',//远程,还有local
   triggerAction:'all',
   applyTo:'local-states'
 }); 

 后台返回(数据JSON格式):

{
   'results':3,
   'row': [
     {'id':1,'name':'Peking'}
     ,{'id':2,'name':'shanghai'}
     ,{'id':3,'name':'shenyang'}]
} 
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics