How to render meta.row after deleting a row?
How to render meta.row after deleting a row?
columnDefs: [ {
{
targets:1,
render: (data, type, row, meta) => meta.row+1
}
} ]
my deleting function:
$('#example').on('click', 'td.editor-delete', function (e) {
var thisrow=$(this)
table.row(thisrow.parents('tr')).remove().draw(true);
})
my function is working perfectly with just one problem which is : after deleting the first row whose meta.row+1 = 1
the second row doesn't take the number 1 (instead of the deleted row) it still 2 it doesn't rendering meta.row after deleting
How to tackle this problem?
Replies
columns.render
might not run after removing the row.Please describe how you are trying to use
meta.row
and maybe we can offer some suggestions.Kevin
@kthorngren
the only usage of meta.row in my website is just to add index to the rows
so what I need is : to change rows meta.row when I remove one of those rows
example
the first row takes meta.row = 1 because I add 1 to meta.row
the second row takes 2
when I remove the first row whose meta.row is 1
the second row still has meta.row = 2
what I need is after removing the first one , second row should have the meta.row 1
Where are you using these indexes?
The
meta.row
value is only accessible incolumns.render
.columns.render
doesn't always run and problem isn't after usingrow().remove()
. This example it doesn't run after removing the row:http://live.datatables.net/gopedote/1/edit
If you want to generate row indexes maybe this example will do what you want.
Kevin