Extjs 如何显示'-';代替网格面板中的空值

Extjs 如何显示'-';代替网格面板中的空值,extjs,Extjs,如何在网格面板中显示“-”以代替空值 代码在这里- var store = Ext.getStore('someStore'); store.each(function (rec) { if(rec.get('comment')=="") { //what code i will write here to edit that cell with '-' } }); 可以尝试将列渲染器添加到网格中 { text: 'Comments', dataI

如何在网格面板中显示“-”以代替空值 代码在这里-

var store = Ext.getStore('someStore');
store.each(function (rec) {
    if(rec.get('comment')=="") {
        //what code i will write here to edit that cell with '-'
    }

});

可以尝试将列渲染器添加到网格中

{ 
  text: 'Comments', 
  dataIndex: 'comment', 
  renderer: function(value, metaData, record, row, col, store, gridView) {
    if (record.get('comment') == "") {
      return "-";
    } else {
      return record.get('comment');
    }
  }
}

查看以了解更多详细信息。

您可以尝试将列渲染器添加到网格中

{ 
  text: 'Comments', 
  dataIndex: 'comment', 
  renderer: function(value, metaData, record, row, col, store, gridView) {
    if (record.get('comment') == "") {
      return "-";
    } else {
      return record.get('comment');
    }
  }
}

查看以了解更多详细信息。

为什么不使用value而不是record.get('comment')?同意,这是更好的解决方案。我只是在使用OP的示例代码。为什么不使用value而不是record.get('comment')?同意,这是更好的解决方案。我只是在使用OP的示例代码。