How to get ids of selected rows and serialize them?

How to get ids of selected rows and serialize them?

maykinomaykino Posts: 10Questions: 2Answers: 0
edited February 2014 in General
Hi, I'm missing something here. I would like to get a serialized value of selected ids in a table. This is what I have:

[code] $('.data-table tr').click(function() {
$(this).toggleClass('row_selected');
});
var oTable = $('.data-table').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
//"sDom": '<"toolbar">frtip',
"sDom": 't<"F"p><"toolbar">',
"aoColumnDefs": [{"bSortable": false, "aTargets": [0]}]
});
function fnGetSelected(oTableLocal)
{
return oTableLocal.$('tr.row_selected');
}


$('#action_menu #close_tickets').click(function(e) {
alert(fnGetSelected(oTable));
e.preventDefault();
});[/code]

Replies

  • allanallan Posts: 63,208Questions: 1Answers: 10,415 Site admin
    [code]
    $( 'tr.row_selected' ).map( function () {
    return this.id;
    } );
    [/code]

    will give you an array of the ids, based on the selector.

    Allan
This discussion has been closed.