fnDeleteRow with jQuery
fnDeleteRow with jQuery
mbstef
Posts: 7Questions: 0Answers: 0
Into the last cell on a table with datatables i use icons for some actions. One of them are a delete-icon, with this the data into this row will delete with ajax. Now i'd like to delete the row also from datatable and i try it to do so:
[code]var row = $(this).closest('tr');
$('.dataTable').dataTable().fnDeleteRow(row);[/code]
But this will delete the wrong row into the table. The datatable object will create in another function and i don't have it globally.
How can i delete the correct row?
Thanks,
Stefan
[code]var row = $(this).closest('tr');
$('.dataTable').dataTable().fnDeleteRow(row);[/code]
But this will delete the wrong row into the table. The datatable object will create in another function and i don't have it globally.
How can i delete the correct row?
Thanks,
Stefan
This discussion has been closed.
Replies
[code]
var id_row = $(this).closest('tr').attr('id');
var nRow = $('#myTable tbody tr[id='+id_row+']')[0];
oTable.fnDeleteRow( nRow, null, true );
[/code]
Assumptions for you:
1. oTable is var oTable = datatable.. etc
2. #myTable is table's id
3. And the reason i can do tr[id= is because I load my data with a DT_RowId field for each row, which DatatTables associates with the tr's.
[code]var row = $(this).closest('tr');
var nRow = row[0];
$('.dataTable').dataTable().fnDeleteRow(nRow);[/code]
will it work correctly.
Thanks hozt ;)
Wow, thanks a lot.
I was struggling with the same problem and this totally solved it.
Perfect !
I use
$('#editable').dataTable().fnDeleteRow('#table-row-'+row_id);
Very good my brother:
and it work well