如何在数据表中的单元格中显示图像而不是bool值?数据表与数据源相关联。
答案 0 :(得分:5)
您可以使用自定义formatter
功能将任何HTML放入您的单元格中。您的列定义可能如下所示:
var myColumnSet = [
{
key: 'active_employee',
label: 'Active',
formatter: function(el, oRecord, oColumn, oData) {
// el is the HTMLElement of the current cell
// oRecord gives you access to other fields from the
// DataSource, e.g.: oRecord.getData('full_name')
// oData is the value of the current field (active_employee)
if (oData) {
el.innerHTML = '<img src="/images/active.png">';
} else {
el.innerHTML = '<img src="/images/not-active.png">';
}
}
},
// other Columns....
];