在Extjs 4中使用getClass隐藏操作列图标

anu*_*mar 4 javascript extjs extjs4

对于网格视图中的每一行,我在操作列中有3个图标,即"编辑","删除","发布".现在我想要的是隐藏发布图标并在某些条件下更改为取消发布图标.(我的记录来自mysql db).

bee*_*gor 5

这是我项目的一个例子.

使用actioncolumn项的getClass属性来实现此目的.要隐藏它,请返回"x-hide-display"类名.

xtype: 'actioncolumn',
  items: [
      {
      getClass: function(v, metadata, r, rowIndex, colIndex, store) {
          // hide this action if row data flag indicates it is not deletable
          if(r.data.deletable == false) {
              return "x-hide-display";
          }
      },
      handler: function(view, rowIndex, colIndex, item, e, record, row) {
          //do something
      },
      icon: 'icons/delete.png'
      }
  ]                             
]
Run Code Online (Sandbox Code Playgroud)

  • 对于那些使用extjs5的人来说,"x-hide-display"已被改为"x-hidden-display" (3认同)