angularjs - celltemplate uigrid 中的条件
问题描述
我想更改单元格 ui 网格中的颜色。请帮忙。这是我的图片: 在此处输入图片描述
解决方案
你有这个 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>';
}
},
推荐阅读
- javascript - 如何格式化 nivo 行中 x 轴的值?
- sql - Postgresql split_part 获取最后一个索引位置
- websphere-liberty - 相对命名空间 - SOAP 调用 - Liberty
- javascript - 如何使用 lodash 对数字字符串字段进行排序
- c# - 使用内部等待的方法处理表单
- azure - 为什么我的应用注册设置需要管理员同意?
- terraform - 使用 Terraform 的 ECS 和 Application Load Balancer 临时端口
- javascript - Discord javascript bot 创建错误“未定义消息”
- javascript - 如何在promise中设置react hook的值?
- python - 预期为“Py_ssize_t”但得到“长”