[英]EXTJS combobox default value after form layout
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 need 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 问题是我需要显示商店的最后一个,但是甚至还有valueField,因为当我点击一个按钮时,这就是我发送给服务器的内容
I did this, but it don't work, it show the last store value, but don't have the valueField 我做了这个,但它不起作用,它显示最后的商店值,但没有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
: 问题是您需要使用valueField
(即idVille
)而不是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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.