var editor; // use a global for the submit and return data rendering in the examples标签:name,edit,datatabes,默认,label,editor,php,data,def From: https://blog.51cto.com/drennetwork/5875354
$(document).ready( function () {
editor = new $.fn.dataTable.Editor( {
ajax: "../php/staff.php" ,
table: "#example" ,
fields: [ {
label: "First name:" ,
name: "first_name"
}, {
label: "Last name:" ,
name: "last_name"
}, {
label: "Position:" ,
name: "position" ,
def: "Software developer"
}, {
label: "Office:" ,
name: "office" ,
def: "Edinburgh"
}, {
label: "Extension:" ,
name: "extn" ,
def: "0000"
}, {
label: "Start date:" ,
name: "start_date" ,
def: function () { return new Date(); },
type: "datetime"
}, {
label: "Salary:" ,
name: "salary" ,
def: "85000"
}
]
} );
$( '#example' ).DataTable( {
dom: "Bfrtip" ,
ajax: "../php/staff.php" ,
columns: [
{ data: null , render: function ( data, type, row ) {
// Combine the first and last names into a single table field
return data.first_name+ ' ' +data.last_name;
} },
{ data: "position" },
{ data: "office" },
{ data: "extn" },
{ data: "start_date" },
{ data: "salary" , render: $.fn.dataTable.render.number( ',' , '.' , 0, '$' ) }
],
select: true ,
buttons: [
{ extend: "create" , editor: editor },
{ extend: "edit" , editor: editor },
{ extend: "remove" , editor: editor }
]
} );
} );