Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在extjs 4中隐藏操作列_Extjs_Extjs4 - Fatal编程技术网

如何在extjs 4中隐藏操作列

如何在extjs 4中隐藏操作列,extjs,extjs4,Extjs,Extjs4,我有一个网格 columns: [ ... { xtype:'actioncolumn', width:40 } ... ] initComponent: function() { var callback=function(hasPerm) { if(!hasPerm) { // I want the action column go away here :) } } is

我有一个网格

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);


}
isgrated是一个全局函数,发送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);
        }
    });
}

如何获取对列的引用以在给定回调函数中隐藏它们<代码>此。列不起作用

更新:合并@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);
    }
  });
}

有一点需要注意:我已经看到列ID在IE8上导致了严重的渲染问题。我不想贬低Justin的答案,因为他有正确的想法,但这里有一些更正:1。默认情况下隐藏“开始操作”列。2.使用show()取消隐藏列。3.不要调用UseDoLayout——这是extjs3的延迟,不再需要。4不使用列ID,而是使用此方法将特定列作为grid.down(“[text=MyColumn]”)的目标。show()--此处“text”是在我的列上定义的属性,但您可以使用您选择的任何属性,即使是自定义属性。