我有一个
的网格columns: [
...
{ xtype:'actioncolumn',
width:40 }
...
]
initComponent: function() {
var callback=function(hasPerm) {
if(!hasPerm) {
// I want the action column go away here :)
}
}
isGranted("users.delete",callback);
}
isGranted是一个全局函数,发送一个ajax请求来检查给定的权限,并在成功事件中使用返回的bool参数调用给定的函数。
isGranted=function(perm, fv) {
Ext.Ajax.request({
url: "/isgranted?perm="+perm,
method: 'POST',
success: function(result) {
var res=new Object();
res=Ext.JSON.decode(result.responseText);
fv(res.success);
}
});
}
如何在给定的回调函数中引用列来隐藏它们? this.columns
没有用。
答案 0 :(得分:1)
更新:纳入@DmitryB建议。好多了。
知道,initComponent不会等待你的ajax调用完成,它将继续并完成构建组件。
columns: [
...
{ xtype:'actioncolumn',
action: 'someaction',
hidden: true,
width:40 }
...
]
initComponent: function() {
var callback=function(hasPerm) {
if(hasPerm) {
this.down('[action=someaction]').show();
}
}
isGranted("users.delete",callback, this);
}
isGranted=function(perm, fv, scope) {
Ext.Ajax.request({
url: "/isgranted?perm="+perm,
method: 'POST',
success: function(result) {
var res=new Object();
res=Ext.JSON.decode(result.responseText);
fv.call(scope, res.success);
}
});
}