Javascript 编辑器\u dataTables-多个表的内联编辑
我正在使用dataTables编辑器,但内联编辑不适用于所有表。Javascript 编辑器\u dataTables-多个表的内联编辑,javascript,php,html,Javascript,Php,Html,我正在使用dataTables编辑器,但内联编辑不适用于所有表。 只有第二个表允许内联编辑。 如何从同一页上的所有表中获取内联编辑? 这两个表都被数据tho填充。 php是 变量编辑器;//对于示例中的提交和返回数据呈现,请使用全局 $(document).ready(function() { editor = new $.fn.dataTable.Editor( { ajax: "../php/staff2.php", "bProcessing": true, "bS
只有第二个表允许内联编辑。 如何从同一页上的所有表中获取内联编辑? 这两个表都被数据tho填充。 php是 变量编辑器;//对于示例中的提交和返回数据呈现,请使用全局
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "../php/staff2.php",
"bProcessing": true,
"bServerSide": true,
table: "#example1",
fields: [ {
label: "subject:",
name: "subject"
}, {
label: "ApplicationDate:",
name: "ApplicationDate"
}, {
label: "PreferedPaymentDate:",
name: "PreferedPaymentDate"
}, {
label: "Ledger:",
name: "Ledger"
}, {
label: "BranchName:",
name: "BranchName"
}, {
label: "AppNumber:",
name: "AppNumber",
}
]
} );
// Activate an inline edit on click of a table cell
$('#example1').on( 'click', 'tbody tb', function () {
editor.inline( this );
} );
$('#example1').DataTable( {
dom: "Tfrtip",
"searching": false,
"bInfo" : false,
"bPaginate": false,
"bSort": false,
"bVisible": false,
ajax: "../php/staff2.php",
columns: [
{ data: null, defaultContent: '', orderable: false },
{ data: "subject" },
{ data: "ApplicationDate" },
{ data: "PreferedPaymentDate" },
{ data: "Ledger" },
{ data: "BranchName" },
{ data: "AppNumber", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) },
],
order: [ 1, 'asc' ],
tableTools: {
sRowSelect: "os",
sRowSelector: 'td:first-child',
aButtons: [
{ sExtends: "editor_create", editor: editor },
{ sExtends: "editor_edit", editor: editor },
{ sExtends: "editor_remove", editor: editor }
]
}
} )
} );
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: "../php/staff2.php",
table: "#example2",
"bProcessing": true,
"bServerSide": true,
fields: [ {
label: "subject:",
name: "subject"
}, {
label: "ApplicationDate:",
name: "ApplicationDate"
}, {
label: "PreferedPaymentDate:",
name: "PreferedPaymentDate"
}, {
label: "Ledger:",
name: "Ledger"
}, {
label: "BranchName:",
name: "BranchName"
}, {
label: "AppNumber:",
name: "AppNumber",
}
]
} );
// Activate an inline edit on click of a table cell
$('#example2').on( 'click', 'tbody td', function () {
editor.inline( this );
} );
$('#example2').DataTable( {
dom: "Tfrtip",
"searching": false,
"bInfo" : false,
"bPaginate": false,
"bSort": false,
"bVisible": false,
ajax: "../php/staff2.php",
columns: [
{ data: null, defaultContent: '', orderable: false },
{ data: "subject" },
{ data: "ApplicationDate" },
{ data: "PreferedPaymentDate" },
{ data: "Ledger" },
{ data: "BranchName" },
{ data: "AppNumber", render: $.fn.dataTable.render.number( ',', '.', 0, '$' ) },
],
order: [ 1, 'asc' ],
tableTools: {
sRowSelect: "os",
sRowSelector: 'td:first-child',
aButtons: [
{ sExtends: "editor_create", editor: editor },
{ sExtends: "editor_edit", editor: editor },
{ sExtends: "editor_remove", editor: editor }
]
}
} );
} );
名字
姓
位置
办公室
开始日期
薪水
名字
姓
位置
办公室
开始日期
薪水
像这样试试
editor1 = new $.fn.dataTable.Editor( { ....for example1 table
editor2 = new $.fn.dataTable.Editor( { ....for example2 table
为其他表选择一个新的变量名,而不是编辑器。很好,谢谢。在('click','tbody td',function(){editor2.inline(this);})上;
<div class="container">
<section>
<table id="example2" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>
<th>First name</th>
<th>Last name</th>
<th>Position</th>
<th>Office</th>
<th width="18%">Start date</th>
<th>Salary</th>
</tr>
</thead>
</table>
editor1 = new $.fn.dataTable.Editor( { ....for example1 table
editor2 = new $.fn.dataTable.Editor( { ....for example2 table