开发者

EXTJS combobox default value after form layout

开发者 https://www.devze.com 2023-01-17 21:24 出处:网络
My combobox\'s data is loaded after the form layout. var villeStore = new Ext.data.ArrayStore({ fields: [{name:\'idVille\'}

My combobox's data is loaded after the form layout.

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'
    });

The problem is that I n开发者_Python百科eed to display the last of the store, but even have the valueField, because when I click on a button, this is what I send to server

I did this, but it don't work, it show the last store value, but don't have the valueField

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


The problem is that you need to set the value of the combo using the valueField (which is idVille) instead of the displayField:

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


Try this:

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

精彩评论

暂无评论...
验证码 换一张
取 消