Here's a jsfiddle to show what I'm talking about:
https://jsfiddle.net/ChakronSA/sdwfcrmr/
You can click and drag on either the "Order" or "Name" columns. To recreate this issue: 1. Drag "Name 4" to the top so it's above "Name 1" 2. Click the Delete button next to "Name 2"
When deleting "Name 2", "Name 4" returns to its original position. How can I make it stay put? I feel like I'm missing something obvious. Thanks.
Specifically curious about why this isn't doing what I expect:
$(document).on("click", ".myTableDeleteRow", function() {
table
.row($(this).parents('tr'))
.remove()
.rows().every(function(rowidx) {
var data = this.data();
data[0] = rowidx + 1;
this.data(data);
})
.draw(false);
});
Heres a fix not using just tableData
$(document).on("click", ".myTableDeleteRow", function() {
table
.row($(this).parents('tr'))
.remove()
.draw(false);
$.each($('#myTable tr td:first-child'),function(index,val){
$(this).html(index+1)
});
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments