列渲染器为您提供输出 HTML 的运行时,您几乎无法高估它的功能...
我不确定我是否完全理解您的问题,但这是一个入门示例。给定一个可能的进程列表,它会显示每条记录的所有进程,并突出显示为此记录标记的进程 (example fiddle):
var processes = ['Foo', 'Bar', 'Baz', 'Bat']; // all available processes
new Ext.grid.Panel({
renderTo: Ext.getBody()
,width: 400
,height: 200
,forceFit: true
,store: {
fields: ['id', 'status', 'statusDetails']
,data: [
{id: 1, status: 'Foo Bar', statusDetails: ['Foo', 'Bar']}
,{id: 2, status: 'Bar Baz', statusDetails: ['Bar', 'Baz']}
,{id: 3, status: 'Baz Bat', statusDetails: ['Baz', 'Bat']}
]
}
,columns: [{
dataIndex: 'id'
,text: "ID"
,width: 40
},{
dataIndex: 'status'
,text: "Status"
,renderer: function(value, md, record) {
md.tdCls = 'processes-cell'; // gives us a hook for CSS
return Ext.Array.map(processes, function(process) {
var statusDetails = record.get('statusDetails');
// possible alternative:
// var statusDetails = record.get('status').split(' ');
return '<div class="process ' + process + ' '
+ (statusDetails.indexOf(process) !== -1 ? 'on' : 'off')
+ '">' + process
+ '</div>';
}).join('');
}
}]
});
随心所欲地设计它。例如:
.processes-cell .process {
display: inline-block;
width: 25%;
text-align: center;
border: 1px solid white;
}
.processes-cell .process.off {
background-color: lightpink;
}
.processes-cell .process.on {
background-color: lightgreen;
}
.processes-cell .x-grid-cell-inner {
padding: 1px;
}