在codeigniter的数据表中弹出框
Posted
技术标签:
【中文标题】在codeigniter的数据表中弹出框【英文标题】:pop_up box in datatables in codeigniter 【发布时间】:2013-06-12 12:57:16 【问题描述】:我想显示一个带有弹出框的 jquery 数据表,所以我遵循了如下所示的方法,这是控制器......但是这个不起作用。错误在于 add_column 的 add_column 的确切语法是什么。
function random()
$this->datatables
->select('c.first_name,o.id')
->from('orders as o')
->add_column(
echo anchor('admin/storedprod/cancel/`o.customer_user_id`', 'cancel', array('onClick' => "return confirm('Are you sure you want to delete?')"))
);
echo $this->datatables->generate();
【问题讨论】:
我不相信你应该在 add_column 函数中使用 echo。你试过删除它吗? 【参考方案1】:我建议您在两个单独的函数中执行此操作。
首先创建jquery数据表。
$(document).ready(function()
$('#example').dataTable();
);
创建你的表
echo ('<table id="example">');
echo ('<thead>');
echo ('<tr>');
echo ('<th>');
echo "First_name";
echo ('</th>');
echo ('<th>');
echo "Id";
echo ('</th>');
echo ('<th>');
echo "Delete";
echo ('</th>');
echo ('</tr>');
echo ('</thead>');
echo ('<tbody>');
foreach( ($data->user_info) as $row)
$first_name = $row['first_name'];
$user_id = $row['user_id'];
echo ('<tr>');
echo ('<td>');
echo ($first_name);
echo ('</td>');
echo ('<td>');
echo ($user_id);
echo ('</td>');
echo ('<td>');
echo "<button type="button" id= "delete">Delete</button>";
echo ('</td>');
echo('</tr>');
echo ('</tbody>');
echo ('</table>'); ?>
然后当你点击删除按钮时,你可以使用jquery ..获取行id ..
$("#delete").live("click", function()
var id = $("td:first", this).text(); // This will get the first column value ( id )
msg = "You are going to delete this " ;
title = "Delete name ";
OK = "OK";
cancel = "COM_CANCEL";
$('#showmsg-content').html(msg);
$("#showmsg").dialog
(
modal: true,
title: title,
width: 550,
buttons:
OK : function()
you can send the id to the model using ajax
$.ajax(
url: url,
async: false,
data: "&id=" + id ,
type : 'post',
success : function()
//row is deleted , refresh the page
$(this).dialog('close');
,
);
$(this).dialog('close');
,
cancel : function()
$(this).dialog('close');
,
);
);
这应该可以。我没有测试这个..试一试..
【讨论】:
以上是关于在codeigniter的数据表中弹出框的主要内容,如果未能解决你的问题,请参考以下文章