我想添加表2中的行在表一。Jquery Datatable添加從一個表到另一個行
如果我選擇在複選框列的行,按添加用戶,將在表中添加該行1
旁邊添加用戶按鈕,我有選擇全或無的一個選項,如果我在輸入點擊全部選中
按下按鈕添加用戶後,表2中的所有行將被添加到表1中。
如果我選擇沒有清除所有複選框
如果我點擊全部選中所有的複選框
的jsfiddle:http://jsfiddle.net/f7debwj2/11/
HTML:
<br>
<br>
<h1>
table1
</h1><br>
<br>
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>First name</th>
<th>Place</th>
<th>Order</th>
</tr>
</thead>
</table>
<br>
<br>
<h1>
table 2
</h1><br>
<br>
<table id="example2" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>First name</th>
<th>Place</th>
<th>checkbox</th>
</tr>
</thead>
</table>
<div class="col-md-12">
<div class="col-md-6">
<button type="button" class="btn btn-success">Add a user</button>
</div>
<div class="col-md-6">select all or none
<div class="btn-group">
<div class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<input type="checkbox" name="vehicle1" value="Bike">
<i class="fa fa-caret-down" aria-hidden="true"></i>
</div>
<ul class="dropdown-menu" role="menu">
<li><a href="#">All</a></li>
<li><a href="#">None</a></li>
</ul>
</div>
</div>
</div>
jQuery的
$(document).ready(function() {
var dt = $('#example').dataTable();
dt.fnDestroy();
});
$(document).ready(function() {
var url = 'http://www.json-generator.com/api/json/get/clmDuyndua?indent=2';
var table = $('#example').DataTable({
ajax: url,
createdRow: function(row, data, dataIndex) {
$(row).attr('id', 'row-' + dataIndex);
},
rowReorder: {
dataSrc: 'order',
},
columns: [{
data: 'order'
}, {
data: 'name'
}, {
data: 'place'
}]
});
table.rowReordering();
});
$(document).ready(function() {
var dt = $('#example2').dataTable();
dt.fnDestroy();
});
$(document).ready(function() {
var url = 'http://www.json-generator.com/api/json/get/cnmZgfsBKa?indent=2';
var table = $('#example2').DataTable({
ajax: url,
createdRow: function(row, data, dataIndex) {
$(row).attr('id', 'row-' + dataIndex);
},
rowReorder: {
dataSrc: 'order',
},
columns: [{
data: 'order'
}, {
data: 'name'
}, {
data: 'checkbox'
}]
});
table.rowReordering();
});
$(document).ready(function() {
$('body').on('mouseenter', 'input', function() {
$('.btn').prop('disabled', true);
});
$('body').on('mouseout', 'input', function() {
$('.btn').prop('disabled', false);
});
});
這裏沒有問題,你可以編輯你的問題,也許只提供與問題相關的代碼, – Nicolas
沒有問題??? – NDFA