根据条件设置单元格的值 [英] Set cell value based on a condition
本文介绍了根据条件设置单元格的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须绑定到一个字段
名为状态
,里面有值的列:取值
或→
。我想这个映射到以下几点:
I have a column binded to a field
called state
, which has the values: S
or L
. I want to map this to following:
取值
=> 短
,→
=> 龙
S
=> Short
,
L
=> Long
这是怎么绑定的定义:
$scope.gridOptions = {
enableSorting: true,
enableFiltering: true,
enableHorizontalScrollbar: 0,
columnDefs: [
{name: 'action', field: 'state', width: 110, enableFiltering: false}
]
};
我已经使用 cellclass
和 celltemplating
,但任何一个用于类的应用程序或事件分别结合。如何设置基于一个单元格值NG-如果
?
I am already using cellclass
and celltemplating
, but either one is used for class application or event binding respectively. How do I set cell value based on an ng-if
?
推荐答案
如果它可以帮助任何人,我结束了这样:
If it helps anyone, I ended up doing this:
let stateTemplate = "<div>{{row.entity.state == 'L' ? 'Buy' : 'Sell'}}</div>
$scope.gridOptions = {
enableSorting: true,
enableFiltering: true,
enableHorizontalScrollbar: 0,
columnDefs: [
{name: 'action', field: 'state', cellTemplate: stateTemplate, enableFiltering: false}
],
data: someData
};
这篇关于根据条件设置单元格的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文