您在这里将布尔值与字符串进行比较,因此所需的结果永远不会发生,因为它总是返回
false
:
if ('USE_IsInactive' == true)
return '<a class="btn btn-primary btn-sm edit" id="' + data + '">Edit</a> <a class="btn btn-success btn-sm acUser" id="' + data + '">Activate</a>';
row
参数并从中使用列名定义:
columns: [
// other columns
{ data: "USE_IsInactive" },
{
data: "USE_Id",
"render": function (data, type, row) {
// row["USE_IsInactive"] may also valid, check them both
if (row.USE_IsInactive === true) {
return '<a class="btn btn-primary btn-sm edit" id="' + data + '">Edit</a> <a class="btn btn-success btn-sm acUser" id="' + data + '">Activate</a>';
}
else {
return '<a class="btn btn-primary btn-sm edit" id="' + data + '">Edit</a> <a class="btn btn-danger btn-sm deacUser" id="' + data + '">Deactivate</a>';
}
}
}
]
If and else condition with DataTables