我有一个网格
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不起作用。
发布于 2012-03-06 06:12:35
更新:合并@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);
}
});
}https://stackoverflow.com/questions/9574417
复制相似问题