I want to delete the row from datatable. Here is the datatables code I use:
var aSelected = [];
oTable = $('.itemPublished').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "/item/datatable",
"bDeferRender": true,
"iDisplayLength":20,
"aLengthMenu": [[10, 20, 50, 75, 100, 150], [10, 20, 50, 75, 100, 150]],
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 2, 3, 4 ] },
{ "sClass": "left", "aTargets": [ 1 ] }
],
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
if ( jQuery.inArray(aData.DT_RowId, aSelected) !== -1 ) {
$(nRow).addClass('row_selected');
}
$(nRow).addClass('gradeA');
return nRow;
}
});
I wanted to test fire an event to delete a row from the datatable. The event is triggered by a button which is outside of datatables table DOM. I tried doing this:
$('.test').live('click', function () {
oTable.fnDeleteRow( 0 );
});
To check if it can delete the first row from the table, but it does not and nor does it produce any error. Where am I going wrong?
Found the following comment here: http://datatables.net/forums/discussion/6208/hyperlink-event-to-delete-row/p1:
"Since you are using server-side processing, and fnDeleteRow knows nothing about your server-side environment, you need to make an Ajax call to the server for it to do the delete and then call fnDraw on the table for it to refresh with the new data set."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With