【发布时间】:2018-08-03 05:33:06
【问题描述】:
我正在使用 CodeIgniter 和 Datatable Server Side 来显示来自数据库的数据。我想从我的 url 视图中获取段 url 并将该段传递给我的控制器并显示到我表中的最后一列。但是没用。
这是我的查看网址
http://localhost/sosboard/admin/module/55
这是我的控制器
function data_module()
{
// Datatables Variables
$submenu_id = $this->uri->segment(3);
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$module= $this->m_admin->main_menu();
$data = array();
//$page = $data['write'];
foreach ($module->result() as $rows) {
$data[] = array(
$rows->title,
$rows->seq,
$rows->target,
$rows->icon_code,
$rows->active,
$submenu_id
);
}
$output = array(
"draw" => $draw,
"recordsTotal" => $module->num_rows(),
"recordsFiltered" => $module->num_rows(),
"data" => $data
);
echo json_encode($output);
}
这是我的 html 视图和 javascript
<div class="panel-body">
<table class='table' id="myTable">
<thead>
<tr>
<th>Main Menu</th>
<th>Seq</th>
<th>Target</th>
<th>Icon Code</th>
<th>Active</th>
<th>Action</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<script>
$(document).ready(function() {
$('#myTable').DataTable({
"ajax": {
"url": "<?php echo site_url('admin/data_module/') ?>",
"type": "GET"
}
});
});
</script>
所有列都很好,但最后一列没有显示。
请帮忙。 谢谢
【问题讨论】:
-
显示数据表html代码
-
查看我的更新代码@PankajMakwana
-
'admin/data_module/'第三个参数为空 -
@AbdullaNilam 我的意思是我想获取当前页面的 url。我的当前页面是localhost/sosboard/admin/module/55,我想获取段 3(模块)。
-
@MardinoIsmail 尝试第 4 段
标签: php codeigniter datatables serverside-javascript