私が使用しています:https://datatables.netのjQueryのDataTable編集行
問題1 - ユーザーは、私が必要なもの、新しい行に
を追加した後、ドラッグ&ドロップが動作しません:からjquery.dataTables.jsを を作ります鉛筆でクリックした後に行を編集できます。このサンプルに似
: https://editor.datatables.net/examples/simple/inTableControls.html
HTML:
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>order</th>
<th>name</th>
<th>country</th>
<th>action</th>
</tr>
</thead>
</table>
<button id="addRow">Add New Row</button>
<table id="newRow">
<tbody>
<tr>
<td><select id="selectbasic" name="selectbasic" class="form-control">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="2">option 3</option>
</select>
</td>
<td>DVap
</td>
<td>
www</td>
<td><i class="fa fa-pencil-square" aria-hidden="true"></i>
<i class="fa fa-minus-square" aria-hidden="true"></i> </td>
</tr>
</tbody>
</table>
jqueryの:
$(document).ready(function() {
var dt = $('#example').dataTable();
dt.fnDestroy();
});
$(document).ready(function() {
var url = 'http://www.json-generator.com/api/json/get/ccTtqmPbkO?indent=2';
var table = $('#example').DataTable({
ajax: url,
rowReorder: {
dataSrc: 'order',
},
columns: [{
data: 'order'
}, {
data: 'place'
}, {
data: 'name'
}, {
data: 'delete'
}],
"initComplete": function(oSettings) {
$(this).on('click', "i.fa.fa-minus-square", function(e) {
table.row($(this).closest('tr')).remove().draw();
});
}
});
// add row
$('#addRow').click(function() {
//t.row.add([1,2,3]).draw();
var rowHtml = $("#newRow").find("tr")[0].outerHTML
console.log(rowHtml);
table.row.add($(rowHtml)).draw();
});
});
jsfiddle: http://jsfiddle.net/5L2qy092/5/
ありがとうございました。このために、最後の1つの追加ボタンが外側の代わりに行の内側にあることができますか?このサンプルとして? http://jsfiddle.net/5L2qy092/8/ – Raduken
@Raduken行くよ、http://plnkr.co/edit/B9fJQwgdLXEqBhrIJI76?p=preview。 回答としてあなたを助けた回答に印を付ける必要があります。 –
ありがとう、私は、最高の男です、あなたの助けを歓迎 – Raduken