简体   繁体   English

如果条件在数据表数据列中

[英]If Condition in datatable data column

I'm trying to add a condition to change what the column displays based on what the data is. 我正在尝试添加条件以根据数据是更改列显示的内容。 So "Status" is "True" or "False". 因此,“状态”为“真”或“假”。 If it's true I want to display "Active" and if it's "False" I want to display "Inactive" 如果是真的,我想显示“活动”,如果是“假”,我想显示“无效”

"aTargets": [2],
"bSortable": false,
"sType": 'numeric',
"sClass": "AutoDashGridStyle",
"sTitle": "Status",
"sWidth": "60px",
"mData": "Status",
"render": function (mData, type, row) {
     return "mData" == 'True' ? 'Active' : 'Inactive'
}

Should display Active or Inactive 应显示有效或无效

Okay so I was able to answer my own question. 好的,我可以回答自己的问题。 I simply changed the mData from 我只是将mData从

"mData": "Status",

to

"mData": function (source) {
return source.Status == "True" ? "Active" : "Inactive";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM