am尝试根据用户类型修改数据表的按钮 如果用户类型= 2,则无需在表格上显示编辑/删除按钮 被尝试,但没有正确的方法 这里的任何专家,请帮助我
<table id="user_groups" class="table table-striped table-hover dt-responsive dm_table" cellspacing="0" style="width: 100% !important; height:auto;">
<thead>
<tr>
<th><?php echo Utils::_('SI No') ?></th>
<th><?php echo Utils::_('Name') ?></th>
<th><?php echo Utils::_('Description') ?></th>
<!-- <th><?php //echo Utils::_('Created On'); ?></th>-->
<th><?php echo Utils::_('Edit') ?></th>
<th><?php echo Utils::_('Delete') ?></th>
</tr>
</thead>
</table>
$(document).ready(function () {
table = $('#user_groups').DataTable({
"displayLength": 6,
"bLengthChange": false,
"ordering": false,
// "scrollY": "250px",
"bFilter": false,
//"scrollX": true,
"scrollCollapse": true,
"paging": true,
"searching": true,
"columns": [
{"data": "no"},
{"data": "group_name"},
{"data": "group_desc"},
//{"data": "date_created"},
{"data": "edit"},
{"data": "delete"}
]
});
我想制作{“ data”:“ edit”}, {“ data”:“ delete”}这是我想有条件给予的
function loadUserGroups() {
$.ajax({
url: '/ajax/UserGroups/getUserGroups',
type: "POST",
success: function (result)
{
if (result.status == 1) {
var result = result.result;
$('#user_groups').dataTable().fnClearTable();
for (var x in result) {
$('#user_groups').dataTable().fnAddData([{
"DT_RowId": result[x].group_id,
"no": result[x].id,
"group_name": result[x].group_name,
"group_desc": result[x].group_desc,
//"date_created": result[x].date_created,
"edit": "<td><a class='edit ui-icon ui-icon-pencil'></a></td>",
"delete": "<td><a class='remove ui-icon ui-icon-trash'></a></td>"
}
]);
}
$('#user_groups').parents('div.dataTables_wrapper').first().show();
table.draw();
} else {
$('#user_groups').dataTable().fnClearTable();
}
}
});
}
这也是这里使用的功能