2010-09-23 23 views
4

我的组合框的数据在表格布局后加载。表格布局后的EXTJS组合框默认值

var villeStore = new Ext.data.ArrayStore({ 
      fields: [{name:'idVille'} 
        ,{name: 'ville'}] 
     }); 
var villeInput = new Ext.form.ComboBox({ 
     fieldLabel: 'Ville', 
     store: villeStore, 
     valueField:'idVille', 
     displayField:'ville', 
     typeAhead: true, 
     mode: 'local', 
     triggerAction: 'all', 
     emptyText:'Ville', 
     width:100, 
     id:'villeInput' 
    }); 

的问题是,我需要显示的最后一个店,但即使有valueField,因为当我点击一个按钮,这是我发送到服务器

我这样做,但它不工作,它显示最后储存价值,但不具备valueField

villeInput.store.on('load',function(store) { 
     villeInput.setValue(store.getAt(villeInput.store.getCount()-1).get('ville')); 
    }); 

回答

1

试试这个:

villeInput.store.on("load", function(store) { 
       villeInput.setValue(ActualidVille, false); 
    }, this); 
+0

它不给我任何东西:( – 2010-09-25 01:43:01

4

的问题是,你需要自行设定的使用组合的价值valueField(这是idVille)的displayField

villeInput.store.on('load',function(store) { 
    villeInput.setValue(store.getAt(villeInput.store.getCount()-1).get('idVille')); 
});