Remove multiple row_selected

Remove multiple row_selected

azhararmarazhararmar Posts: 6Questions: 0Answers: 0
edited April 2012 in DataTables 1.8
hi,
i am using ajax to perform some operation like multiple publish/unpublish rows. i am using two datatables the first one contains the datatables with published items and the other one with unpublished items. i am using multiple row select. here is the code i am using for multiple row select.

[code]
//Datatable select muiltiple rows.
var aSelected = [];
$('.dTable tbody tr').live('click', function () {
var id = this.id;
var index = jQuery.inArray(id, aSelected);
if ( index === -1 ) {
aSelected.push( id );
} else {
aSelected.splice( index, 1 );
}
$(this).toggleClass('row_selected');
});
[/code]

and here is my ajax code. what i want is on success function of ajax i want to remove all the selected rows here is my ajax code.

[code]
$.ajax({
type: 'POST',
url: "/admin/item/delete",
data: 'item='+aSelected,
success: function(data) {
item_published.fnDraw();
item_unpublished.fnDraw();
}
});
[/code]

my two datatables initialization code here.
[code]
var item_published = $('#item_published').dataTable();
var item_unpublished = $('#item_published').dataTable();
[/code]

i want to remove all the row_selected class from the tables. in the success: event of ajax. i tried doing several things but nothing work for example

[code]
$("td.row_selected", item_published.fnGetNodes()).removeClass('row_selected');

$(item_published.fnSettings().aoData).each(function(){
$(this.nTr).find("td").removeClass('row_selected');
});
[/code]

nothing is working. what is the correct way of achieving what i want?

Thank you

Replies

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Try this:

    [code]
    item_published.$("td.row_selected").removeClass('row_selected');
    [/code]

    Allan
This discussion has been closed.