我使用datatables-examples中的SSI-Solution。
现在,我想更改和编辑数据库的一些结果(例如,我想通过这个id等的图标更改存储的id。)。
目前我没有想法,我可以抓住结果并与他们合作。也许有人可以帮我解释一下。
以下是用于获取数据库结果的代码
// DB table to use
$table = 'MODUL_1_CONTACTS';
// Table's primary key
$primaryKey = 'ACCOUNT_ID';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'CONTACT_GROUP', 'dt' => 0 ),
array( 'db' => 'KD_NO', 'dt' => 1 ),
array( 'db' => 'TYPE', 'dt' => 2 ),
array( 'db' => 'ORG_NAME', 'dt' => 3 ),
array( 'db' => 'VORNAME', 'dt' => 4 ),
array( 'db' => 'NAME', 'dt' => 5 )
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( $vz.'assets/global/plugins/datatables/ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $table, $primaryKey, $columns )
);
这是JS代码
var table = $('#ajax_table1').DataTable( {
"processing": true,
"serverSide": true,
"ajax": $.fn.dataTable.pipeline( {
url: 'data.php',
pages: 5 // number of pages to cache
} ),
"columnDefs": [
{
"targets": -1,
"data": null,
"defaultContent": "<button class=\"btn yellow-mint uppercase btn-circle\" data-toggle=\"confirmation\" id=\"bs_confirmation_demo_1\">Confirmation 1</button><div class=\"btn-group pull-right\"><button class=\"btn green btn-xs btn-outline dropdown-toggle\" data-toggle=\"dropdown\">Tools<i class=\"fa fa-angle-down\"></i></button><ul class=\"dropdown-menu pull-right\"><li><a href=\"javascript:;\"><i class=\"fa fa-trash\"></i> delete </a></li><li><a href=\"javascript:;\"><i class=\"fa fa-file-text\"></i> write letter </a></li><li><a href=\"javascript:;\"><i class=\"fa fa-calendar-plus-ot\"></i> new todo/date </a></li><li><a href=\"javascript:;\"><i class=\"fa fa-file-cubes\"></i> new work </a></li><li><a href=\"javascript:;\"><i class=\"fa fa-print\"></i> Print </a></li><li><a href=\"javascript:;\"><i class=\"fa fa-file-pdf-o\"></i> Save as PDF </a></li><li><a href=\"javascript:;\"><i class=\"fa fa-file-excel-o\"></i> Export to Excel </a></li></ul></div>"
}],
"language": {
url: '../lang/<?php echo $_GET['lang'].'/'.$_GET['lang']; ?>.json'
},
// setup buttons extentension: http://datatables.net/extensions/buttons/
buttons: [
{ extend: 'print', className: 'btn dark btn-outline' },
{ extend: 'pdf', className: 'btn green btn-outline' },
{ extend: 'csv', className: 'btn purple btn-outline' }
],
"lengthMenu": [
[5, 10, 15, 20, -1],
[5, 10, 15, 20, "All"] // change per page values here
],
//responsive: true,
"bFilter": true,
// set the initial value
"pageLength": 10,
//Layout
"dom": "<'pull-left'f><'pull-right' B>r<'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>><'row'<'col-md-5 col-sm-12'l><'col-md-7 col-sm-12'>>",
} );