我想更改单元格ui网格中的颜色。请帮忙。 这是我的形象: enter image description here
答案 0 :(得分:0)
您具有此ID的单元格模板:
{
field: 'BookingId',
displayName: 'ID',
cellTemplate: function () {
return '<div class="ui-grid-cell-contents" style="background-color:lightblue;" ng-if="row.entity.BookingId == \'19\'">{{row.entity.BookingId}}</div><div class="ui-grid-cell-contents" style="background-color:LightCoral;" ng-if="row.entity.BookingId == \'18\'">{{row.entity.BookingId}}</div>';
}
}
它可能是这样的:
{
field: 'BookingId',
displayName: 'ID',
cellTemplate: function () {
let color = 'white';
if (row.entity.BookingId.indexOf('C') !== -1) { color = 'lightblue'; }
else if (row.entity.BookingId.indexOf('V') !== -1) { color = 'lightred'; }
else if (row.entity.BookingId.indexOf('P') !== -1) { color = 'lightgreen'; }
return '<div class="ui-grid-cell-contents" style="background-color:' + color + ';" ng-if="row.entity.BookingId == \'19\'">{{row.entity.BookingId}}</div><div class="ui-grid-cell-contents" style="background-color:LightCoral;" ng-if="row.entity.BookingId == \'18\'">{{row.entity.BookingId}}</div>';
}
},