Reputation: 59
I am using the latest version of the jQuery datatables. Is there a callback function that called when row is deleted?
I have dynamic table where data can be reloaded and changed during page life. I need to ensure that ID column contains unique values and for this I'm concatenating instance number to the IDs, doing this in rowCreated callback.
I'm holding object that contains already existing IDs, adding new ID in createdRow callback and looking for way to remove already deleted IDs.
my createdRow code:
"createdRow": function (row, data, index) {
if (!data || data.length == 0) return;
var id;
if(firstRender ||
data[INDEX_ID].toString().indexOf('.') == -1) {
id = (data[INDEX_ID]).toString();
id = generateKey(id, ID_MAP);
data[INDEX_ID] = id;
ID_MAP[id] = row;
}
}
want to add something like:
"destroyedRow"(row, data){
ID_MAP.remove(data[INDEX_ID]);
}
Thanks.
Upvotes: 0
Views: 645
Reputation: 100195
you could use fnDeleteRow() function and then remove the index, as:
var oTable = $('#example').dataTable(),
rowID = 1;
oTable.fnDeleteRow( rowID );
//remove ID from your array
Upvotes: 1