日期:2014-05-16  浏览次数:20386 次

EXT 级联小问题
{
xtype:"combo",
mode:'local',
valueField:'xiaoqu',
displayField:'xiao',
width: 100,
triggerAction:'all',
emptyText: '请选择',
store:this.store1,
listeners:
{
scope: this,
'select' : function(cb)
{
var selectedId = cb.getValue();
this.store2.loadData(data2[selectedId-1]);
}
}
},
{
xtype:"combo",
mode:'local',
valueField:'value',
displayField:'text',
width: 100,
emptyText: '请选择',
triggerAction:'all',
store:this.store2
},
 getStore1: function() {
  var store1 = new Ext.data.SimpleStore({
data:this.data1,
fields:['xiaoqu','xiao']
  });
  return store1;
  },
  getStore2: function() {
  var store2 = new Ext.data.SimpleStore({
data:this.data2,
fields:['value','text']
  });
  return store2;
  },
getData1:function(){
  var data1=
  [
  ['1','育新小区'],
  ['2','东村家园'],
  ['3','富力桃园']
  ]; 
  return data1;
  },
  getData2:function(){
  var data2= new Array();  
  data2[0] = 
  [
  ['11','表1'],
  ['12','表2']
  ];  
  data2[1] = 
  [
  ['21','表3'],
  ['22','表4']
  ];
  data2[2] = 
  [
  ['31','表5'],
  ['32','表6']
  ]; 
  return data2;
  },

------解决方案--------------------
listeners:
{
'select' : function(cb)
{
var selectedId = cb.getValue();
this.store2.loadData(this.data2[selectedId-1]);
},
scope:this
}