ext 简单 json定义 combo
Ext.ux.ComboBox = function(config) {
if (Ext.isArray(config.store)) {
var store = [];
for (var i = 0, len = config.store.length; i < len; i++)
store[i] = [config.store[i]];
config.store = new Ext.data.JsonStore({
fields : ['valuefield', 'displayfield'],
data : config.store
});
config.valueField = 'valuefield';
config.displayField = 'displayfield';
}
Ext.ux.ComboBox.superclass.constructor.call(this, config);
}
Ext.extend(Ext.ux.ComboBox, Ext.form.ComboBox, {
});
Ext.reg('comboux', Ext.ux.ComboBox);
if (Ext.isArray(config.store)) {
var store = [];
for (var i = 0, len = config.store.length; i < len; i++)
store[i] = [config.store[i]];
config.store = new Ext.data.JsonStore({
fields : ['valuefield', 'displayfield'],
data : config.store
});
config.valueField = 'valuefield';
config.displayField = 'displayfield';
}
Ext.ux.ComboBox.superclass.constructor.call(this, config);
}
Ext.extend(Ext.ux.ComboBox, Ext.form.ComboBox, {
});
Ext.reg('comboux', Ext.ux.ComboBox);
用法:
{width:"233",store:[{valuefield:"1",displayfield:"男"},{valuefield:"2",displayfield:"女"},{valuefield:"3",displayfield:"李宇春} ],allowBlank:false
,fieldLabel:"性别",mode:"local",xtype:"comboux",readOnly:true,displayField:"displayfield",valueField:"valuefield"
,name:"gm",triggerAction:"all",hiddenName:'gm'}
,fieldLabel:"性别",mode:"local",xtype:"comboux",readOnly:true,displayField:"displayfield",valueField:"valuefield"
,name:"gm",triggerAction:"all",hiddenName:'gm'}