function comboData(jsonStr){
//var obj = jsonStr.parseJSON();
//alert(obj.abbr);
return JSON.parse(jsonStr);
}
var ds;
Ext.onReady(function() {
ds=Ext.create('Ext.data.Store',{
fields : [ {
name : 'name',
type : 'int'
}, ],
proxy:{
type:'ajax',
url:'${contextPath}/getNeedLoginWebGroup.${actionExtension}',
reader:{
type:'json',
rootProperty:'rows',
}
},
});
var isForm = Ext.widget('form', {
id:'isform',
width: 700,
bodyPadding: 10,
height: 400,
renderTo: 'itemselector',
layout: 'fit',
tbar: [
{ xtype: 'combo', id:'wlid',fieldLabel:'白标',dock:'top', labelAlign:'right',
store:Ext.create('Ext.data.Store',{
fields:['name','abbr'],
data:comboData('${cmyJsonStr}')
}),
displayField:'name',
valueField:'abbr',
listeners:{
afterrender:function(com){
com.select("");
},
change:function(){
var container=Ext.getCmp('groupName');
var groupNameURL = "${contextPath}/listGroupNamesWebGroup.${actionExtension}";
container.removeAll(true);
$.post(groupNameURL,{'model.whiteid':Ext.getCmp('wlid').value},function(datas){
container.add({
xtype:'combo',
id:'groupNames',
matchFieldWidth:false,
editable:false,
store:Ext.create('Ext.data.Store',{
fields:['name','abbr'],
data:comboData(datas)
}),
displayField:'name',
valueField:'abbr',
listeners:{
change:function(){
var i=isForm.getForm().findField("itemselector");
i.reset.call(i);
var param=new Object();
var name='model.groupName';
var value=Ext.getCmp('groupNames').value;
param[name]=value;
ds.getProxy().setExtraParams(param);
ds.load();
}
}
});
})
}
}
},
{xtype:'fieldcontainer',id:'groupName',dock:'top',fieldLabel:'网站组',
labelAlign:'right',
layout:{
type:'hbox',
align:'stretch',
}
},
],
items:[{
xtype: 'itemselector',
name: 'itemselector',
id: 'itemselector-field',
anchor: '100%',
html:"",
store: ds,
displayField: 'name',
valueField: 'name',
fromTitle: '可用账号',
toTitle: '已选账号'
}],
//注释的部分报错:Uncaught TypeError: Cannot read property 'model' of undefined
/* items:[{
xtype: 'itemselector',
id : '_left',
//imagePath: '../ux/images/',//左右移动的图片
fromTitle: '可用账号',
toTitle: '已选账号',
multiselects: [{ //定义左边数据
store: ds,
displayField: 'name',
valueField: 'name'
},{ //定义右边为空数据
id:'_right',
store: []
}],
}], */
});
});