我正在尝试向我的表中添加一些功能,允许用户选择一行或多行,以便在用户单击删除按钮后,它将向服务器发送 Ajax 请求,从该服务器中删除表中的项目。我一直在查看数据表网站,该网站是我添加到页面的脚本,其中有很多内容,我不确定我到底需要什么来完成这个。
$( '#table' ).dataTable({
"sDom": '<"top"lTf<"clear">>rt<"actions"<"actions-left"i><"actions-right"p>>',
"bAutoWidth": false,
"sPaginationType" : "full_numbers",
"oTableTools": {
"aButtons": [
{
"sExtends": "text",
"sButtonText": "Add"
},
{
"sExtends": "text",
"sButtonText": "Edit"
},
{
"sExtends": "text",
"sButtonText": "Delete",
"sAjaxUrl": "delete_title"
},
]
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0 ] },
{ "sWidth": "20px", "aTargets": [ 0 ] },
{ "sWidth": "40px", "aTargets": [ 1 ] },
{ "sClass": "alignCenter", "aTargets": [ 1 ] }
]
});
<?php
$tmpl = array ( 'table_open' => '<table class="table" id="titles-table">' );
$data = array('name' => 'titles', 'class' => 'selectall');
$this->table->set_heading(form_checkbox($data), 'ID', 'Title Name', 'Style', 'Status');
$this->table->set_template($tmpl);
foreach ($titles as $row)
{
$checkbox_data = array(
'name' => 'titles',
'id' => $row->id
);
$this->table->add_row(form_checkbox($checkbox_data), $row->id, $row->title_name, $row->type_name, $row->status_name);
}
echo $this->table->generate();
?>
有没有其他人看到我错过了什么?