在 Extjs 中删除渲染器中的 HTML

removing the HTML inside the renderer in Extjs

我正在尝试删除放置在网格列渲染器内的按钮。 但是我所做的删除了该列中的所有按钮:

_rendererImportBtnDisplay : function(value, metaData, record, rowIndex,   colIndex, store, view) {
        var loop = store.getRange();
        Ext.each(loop,function (record) {
              var btn = record.data.importButton;
          if(btn == true){
                return "";
              }
          }else{
              return "<span class='btn_import_file'><button>Import</button></span>";
          }
     });
}, 

但我只想删除以下按钮:

var btn = record.data.importButton;

returns

true

对于特定的列。 有什么办法可以实现吗?

Ext.each 将函数应用于数组的每个成员。它基本上是一种更方便的 for 循环形式。 Return 每个函数的 false 将停止迭代。但它不会像您尝试的那样从容器函数中导致 return 。您应该编写如下所示的代码,因为记录可作为 renderer 函数的参数使用。

_rendererImportBtnDisplay : function(value, metaData, record, rowIndex,   colIndex, store, view) {          
       if(record.data.importButton == true){
           return "";
       }else{
           return "<span class='btn_import_file'><button>Import</button></span>";
       }
}