toArray() pulling all info, not just selected row/s.

toArray() pulling all info, not just selected row/s.

socialinteractionssocialinteractions Posts: 2Questions: 1Answers: 0
edited September 2018 in Free community support

Hi Guys,

I'm trying to pass the values from selected rows to an array using toArray().

I'm testing using a button with an event attached to it. If I select one row with, then click the button, it displays an array of the vales in the column for ALL records, while the count alert (correctly) shows one row selected.

Here is the jquery...

$(document).ready( function () {
    var table = $('#volunteers').removeAttr('width').DataTable( {
        scrollY:        "800px",
        scrollX:        true,
        select: true,
        scrollCollapse: true,
        columnDefs: [
            { "width": "150", "targets": 0 }
        fixedColumns: true
    } );
$('#selected').click(function () {
var array = table.rows('.selected')
        alert( table.rows('.selected').data().length +' row(s) selected' );
} );

Any suggestions as to what I may be doing incorrectly?



This question has an accepted answers - jump to answer


Sign In or Register to comment.