2016-10-06 12 views

答えて

0

Ext.define('Bind.CL.FormD.view.MyCombo', { 
    extend: 'Ext.form.field.Picker', 
alias: 'widget.mycombo', 

...something code... 

this.on('expand', function() { 
      var combo = Ext.ComponentQuery.query('mycombo')[0]; 
      var value = combo.getValue(); //or getRawValue(); 
     }, this); 

をしかし、それは動作しません:https://fiddle.sencha.com/#fiddle/1i0o

Ext.application({ 
name: 'Fiddle', 

launch: function() { 
    simpsonsStore = Ext.create('Ext.data.Store', { 
    storeId : 'simpsonsStore', 
    fields : ['id','name', 'email'], 
    data : [ 
     {name : 'Lisa',email : '[email protected]',id:1}, 
     {name : 'Bart', email : '[email protected]',id:2}, 
     {name : 'Homer', email : '[email protected]',id:3}, 
     {name : 'Marge',email : '[email protected]',id:4} 
    ] 
}); 

    Ext.create('Ext.form.field.ComboBox', { 
     emptyText: "Hello", 
     growMax: 10, 
     valueField: 'id', 
     store:simpsonsStore, 
     displayField: 'name', 
     editable: false, 
     queryMode: 'local', 
     renderTo: Ext.getBody(), 
     listeners:{ 
      change:function(combo){ 
       console.log(combo.store.indexOf((combo.store.getById(combo.value)))); 
      } 
     } 
    }); 
} 
}); 
+0

ありがとう! :) しかし、ストアは未定義です。どうしてですか?( https://i.imgsafe.org/5f6d80b3c7.png – ruslanen

+0

フィドルを確認してください –

+0

ありがとう – ruslanen

0

マイ:
をフィドルをチェックしてください。ソリューション:

this.on('expand', function() { 
     var combo = Ext.ComponentQuery.query('mycombo')[0], 
      value = combo.getValue(), 
      root = value.store.tree.getRootNode(), 
      record = root.childNodes, 
      currentValue = combo.getValue().data.Code, 
      index = 0; 

    Ext.each(record, function(element) { 
     var data = element.getData(); 

     if (data.Code === currentValue) { 
      return false; 
     } 

     index++;  
    }); 
関連する問題