87,915
社区成员
发帖
与我相关
我的任务
分享
var roleStore = new Ext.data.JsonStore({
url : URL_ROLESTORE,
root : "result",
fields : ['id', 'authority', 'description']
});
roleStore.load();
component.list.RoleList = Ext.extend(Ext.grid.GridPanel, {
store : roleStore,
sm : new Ext.grid.RowSelectionModel({
singleSelect : true
}),
initComponent : function() {
this.addEvents({
selectrole : true
})
this.columns = [
{
xtype : 'gridcolumn',
dataIndex : 'authority',
header : LABEL_ROLE_AUTHORITY,
sortable : true
}, {
xtype : 'gridcolumn',
dataIndex : 'description',
header : LABEL_ROLE_DESCRIPTION,
sortable : true
} ];
this.sm.on("rowselect",this.onSelectRole);
component.list.RoleList.superclass.initComponent.call(this);
},
onSelectRole : function(sm, rowIdx, r){
this.fireEvent('selectrole', this, sm, rowIdx, r);
}
});
Ext.reg('rolelist', component.list.RoleList);
application.user.UserPrivilege = Ext.extend(Ext.Panel, {
title : TITLE_USERPRIVILEGE,
layout : 'border',
initComponent : function(){
this.items=[{
layout: "vbox",
split : true,
region: "center",
items : [
this.buildUserList(),
this.buildUserInfoForm()
]
},this.buildRoleList()
];
application.user.UserPrivilege.superclass.initComponent.call(this);
},
buildRoleList : function(){
return {
xtype : "rolelist",
region : "west",
width : 300,
id : "rolelist",
listeners : {
scope : this,
'selectrole' : function(){alert("ok")}
}
}
},
buildUserList : function(){
return {
xtype : "userlist",
flex : 1,
id : "userlist",
split : true,
listeners : {
}
}
},
buildUserInfoForm : function(){
return {
xtype : "userinfoform",
flex : 1,
width : "100%",
id : "userinfo",
split : true,
onSaveUser : function(){
this.el.mask('Please wait', 'x-mask-loading');
this.getForm().submit({
method : "POST",
success : function(form,action){
this.el.unmask();
this.findById("userNameField").disable();
Ext.MessageBox.alert("Prompt", "save success");
this.findById("passwordField").hide();
this.findById("rePasswordField").hide();
Ext.getCmp("userlist").getStore().reload();
},
failure : function(form,action){
this.el.unmask();
Ext.MessageBox.alert("Prompt", "save faild");
}
})
},
onNewUser : function(){
this.getForm().reset();
this.findById("passwordField").show();
this.findById("rePasswordField").show();
this.getForm().url=URL_NEWUSER;
this.findById("userNameField").enable();
roleNotAssignedStore.load();
}
}
},
onRoleListClick : function(rolelist,sm,rowIdx,d){
alert(d);
userStore.proxy.setUrl(URL_USERLISTBYROLE);
/*
this.getSelectionModel().on('rowselect',function(sm, rowIdx, r){
var store=userList.getStore();
store.proxy.setUrl(URL_USERLISTBYROLE);
store.load({params:{roleId:r.data.id}});
});*/
}
});
initComponent:function(){
.........
this.addEvents('gridRowClk');
this.on('rowclick',this.clkByGrid,this);
},
clkByGrid:function(g,i,e){
this.fireEvent('gridRowClk',g,i,e);
}
使用:
this.on('gridRowClk',this.loadByGrid,this);
loadByGrid:function(g,i,e){}
this.addEvents({
selectrole : true
})