我的目标是将数据库中的每个“OUT”或“IN”更改为红色或绿色圆圈,但没有任何变化,也没有错误。在 IN 和 OUT 列中将包含值“IN”和值“OUT”,我想转换为绿色圆圈或红色圆圈。
我不知道我做错了什么。
看法
<th scope="col">Name</th>
<th scope="col" id="IN">IN</th>
<th scope="col" id="OUT">OUT</th>
<th scope="col">Comments</th>
js
<script>
$('table').DataTable({
searching: false, paging: false,
"ajax": {
url : "<?php echo site_url("getStatu") ?>",
type : 'GET',
},
"columnDefs": [
{
"data" : "OUT", "orderable" : false, "defaultContent" : "",
"render": function ( data, type, full, meta) {
if (data=="OUT")
{
return data ='<i class="fa fa-circle" style="font-size:36px; color:red"></i>'
}
},
}, ]
});
控制器
public function getStatu(){
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$this->load->model('Status_Board_Model');
$status = $this->Status_Board_Model->getStatu();
$data = array();
foreach($status->result() as $r) {
$data[] = array(
$r->firstName,
$r->online,
$r->offline,
$r->comment,
);
}
$output = array(
"draw" => $draw,
"recordsTotal" => $status->num_rows(),
"recordsFiltered" => $status->num_rows(),
"data" => $data
);
echo json_encode($output);
}
一只甜甜圈
开心每一天1111