新做的extjs二级下拉,兼容谷歌、火狐、iE浏览器。extjs官方文档里建议使用create而不使用new等关键字
extjs的var me = this;用的真的是到了极致。下面便有var me = this;的应用
Ext.define('Module.YB.XXXX.view.XXXXForm', {
extend : 'Ext.form.Panel',
labelWidth: 60,
frame: true,
width: 500,
defaults: {
labelAlign: 'right',
width: 400
},
templateTypeData:function(templateTypeData){
var me = this;
},
initComponent : function() {
var me = this;
var comStore = [];
var tempData = me.templateTypeData;
$.each(tempData.dictItems,function(key,value){
comStore.push("['"+value.value+"'","'"+value.name+"']");
});
var typeNumStore = new Ext.data.SimpleStore({ //这里最好使用create
fields:['name', 'name'],
proxy:{
type: 'rest',
headers : {
"Content-Type": "application/json; charset=utf-8",
Accept : 'application/json'
},
reader: {
type: 'json',
successProperty:'success',
root: 'datas'
}
}
});
me.items = [{
name : 'templateFile',
xtype : 'filefield',
fieldLabel : TEMPLATE_PROPERTY.fileName,
regex : /.+(.zip)$/,
emptyText: TEMPLATE_PROPERTY.uploadFileType,
regexText : TEMPLATE_PROPERTY.uploadFileType,
buttonText : TEMPLATE_PROPERTY.fileButton,
msgTarget : "side",
submitValue : true,
allowBlank : false
},{
xtype:"combo",
editable:false,
queryMode: 'local',
store:new Ext.data.SimpleStore({
fields : ['key', 'value'],
data : eval('['+comStore+']')
}),
valueField: 'key',
displayField: 'value',
fieldLabel : TEMPLATE_PROPERTY.type,
name : 'type',
emptyText: TEMPLATE_PROPERTY.type,
maxLength:50,
allowBlank : false,
listeners:{
select : function(combo, record,index){
typeNumStore.proxy.url='/template/name/'+combo.value; //给已经定义好的store的url赋值
typeNumStore.load();
}
}
},{
xtype:"combo",
editable:false,
queryMode: 'local',
store:typeNumStore,
valueField: 'name',
displayField: 'name',
fieldLabel : TEMPLATE_PROPERTY.name,
name : 'name',
emptyText: TEMPLATE_PROPERTY.name,
maxLength:50,
allowBlank : false
}];
me.callParent();
}
});