关于extjs combobox 在 IE 中无法正常显示的问题解决 ,我们经过分析实现,最后给解决办法。下面看实例。
combobox中的数据由服务端数据填充,刚一开始很多网上的例子都是少了一句,如下
var companies = new Ext.data.JsonStore({
url: '/Company/GetCompanies/',
root: 'companies',
fields: [
{ name: 'CompanyID' }, { name: 'CompanyName'}]
});
ComboBox的实现:
new Ext.form.ComboBox({
fieldLabel: 'Company',
typeAhead: false,
triggerAction: 'all',
valueField: 'CompanyID',
hiddenName: 'CompanyID',
displayField: 'CompanyName',
mode: 'remote',
lazyRender: true,
store: companies,
allowBlank: true,
editable: false,
listeners: {
'focus': function () {
if (companies.data.length > 0) {
debugger; // 这个用来调试.
}
}
}})
返回Json串{"companies":[{"CompanyID":1,"CompanyName":"Test"},{"CompanyID":2,"CompanyName":"Test1" },{"CompanyID":3,"CompanyName":"Test2"}]}
结果是在火狐中显示正常,但是在IE中无法正常显示
解决方法很简单,把store改为如下:
var companies = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '/Company/GetCompanies/',
method: 'GET'//这里是重点****************
}),
reader: new Ext.data.JsonReader({
root: 'companies'
},
[{ name: 'CompanyID', mapping: 'CompanyID' },
{ name: 'CompanyName', mapping: 'CompanyName' }
])
});