87,997
社区成员




<th data-options="field:'exist',width:50,align:'right',formatter:formatexist">存在</th>
<th data-options="field:'_operate',width:80,align:'center',formatter:formatOper">操作</th>
function formatOper(val, row, index) {
return '<a href="#" id="confirmUser' + index + '" onclick="confirmUser(' + index + ')">存在</a> <a href="#" id="cancelUser' + index + '" onclick="cancelUser(' + index + ')">不存在</a>';
}
function formatexist(val, row, index) {
if (val == "0") {
$('#cancelUser' + index).hide();
return "否";
}
if (val == "1") {
$('#confirmUser' + index).hide();
return "是";
}
}
row就是当前数据行,直接取row.exist的值判断返回就行了
function formatOper(val, row, index) {
return row.exist == '0' ? '<a href="#" id="confirmUser' + index + '" onclick="confirmUser(' + index + ')">存在</a>'
: '<a href="#" id="cancelUser' + index + '" onclick="cancelUser(' + index + ')">不存在</a>';
}
function formatexist(val, row, index) {
if (val == "0") {
// $('#cancelUser' + index).hide();
return "否";
}
if (val == "1") {
// $('#confirmUser' + index).hide();
return "是";
}
}