【发布时间】:2016-04-20 10:18:17
【问题描述】:
我将 CodeIgniter 和 DataTables(link) 与库 IgnitedDatatables(link) 一起使用。
我不知道如何在 DataTables 中使用类似 strip_tags() 的东西。我只需要从 JSON 数据中删除所有 html 标记输出。
我的 JavaScript 代码:
var table = $('#dtslider').DataTable({
ajax: {
url: baseurl + 'admin/Administrator/getdata_slider',
type: "POST"
},
processing: true,
serverSide: true,
columns: [{
data: "idHome",
visible: false
}, {
data: "jdlHome"
}, {
data: "isiHome",
sType: 'html'
}, {
data: "Actions",
searchable: false
}],
"order": [
[0, "asc"]
]
});
HTML 代码:
<div class="box-body">
<div class="order-column">
<table id="dtslider" class="table table-striped table-bordered">
<thead class="dt-right">
<tr>
<th>id</th>
<th>Judul Panel</th>
<th>Isi Panel</th>
<th>Actions</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<!-- /.box-body -->
输出: 在图像输出中,在第 2 行和第 3 行有强。我需要删除输出中的所有 html 标签。我已经尝试过类似 sType 和 createdrow 的方法,但仍然没有结果。也许是因为我还是 DataTables 和 JavaScript 的新手。有人可以帮我吗?
编辑(更多代码):
获取数据滑块:
public function getdata_slider()
{
$column = 'idHome, jdlHome, isiHome';
$id = 'idHome';
$table = 'home';
$columnwhere = 'ketHome';
$key = '1';
$this->Model_administrator->getDatatablesCustom2($column, $id, $table, $columnwhere, $key);
echo $this->datatables->generate();
}
getDatatablesCustom2:
public function getDatatablesCustom2($column, $id, $table, $columnwhere, $key)
{
$this->load->library('Datatables');
$this->load->helper('Datatables_helper');
$this->datatables->select($column)->where($columnwhere, $key)
->unset_column('file')
->add_column('file','<a href="'.base_url("assets/uploads/$1").'">$1</a>', 'file')
->add_column('Actions', get_buttons('$1'), $id)
->from($table);
}
【问题讨论】:
-
我猜这是服务器端问题 - 您应该在 getdata_slider 函数中执行此操作
-
你能给我更多的指针或例子我必须在 getdata_slider 做什么吗?我在刚才的帖子里写代码。
标签: javascript json codeigniter datatables