gpt4 book ai didi

javascript - 在 codeigniter 的数据表中弹出框

转载 作者:行者123 更新时间:2023-11-30 06:31:42 27 4
gpt4 key购买 nike

我想显示一个带有弹出框的 jquery 数据表,所以我遵循了如下所示的方法,这是 Controller ……但是这个不起作用。错误出在 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();
}

最佳答案

我建议您在两个单独的函数中执行此操作。

首先创建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');
}
},
});
} );

这应该有效。我没有测试这个..试一试..

关于javascript - 在 codeigniter 的数据表中弹出框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17132829/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com