Getting value from hidden row column

Getting value from hidden row column

rpanditrpandit Posts: 14Questions: 0Answers: 0
edited January 2014 in DataTables 1.9
I have 7 columns in my datatable with 2nd column is invisible and storing Message Id. 3rd column is a checkbox which is visible and i am storing Message Id value there too. Currently when someone checks checkbox i am collecting Message Id value from the checkbox but i don't want to store Message Id value in checkbox instead would like to collect it from the invisible second column.I want to do that in my function event.

function saveCheckedMessages(){
var msgIds = new Array();
$("#tblInbox td input[type=checkbox]:checked").each(function () {
msgIds.push(convertStringToInt($(this).val()));
});
}

How can i achieve that?
here's the link for Datatable
http://debug.datatables.net/ecevic

Replies

  • rpanditrpandit Posts: 14Questions: 0Answers: 0
    sorry,
    actually this is the correct link
    http://debug.datatables.net/ajuhed
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    If you fancy giving 1.10 a whirl ( http://datatables.net/download - the DataTables "nightly") you could use:

    [code]
    var table = $('#example').DataTable();

    table
    .column( 2 )
    .flatten()
    .map( function (idx, i) {
    if ( $('input:checked', table.cell( idx, 2 ).node()).length ) {
    return table.cell( idx, 1 ).data();
    }
    return null;
    } )
    .filter( function ( val ) {
    return val !== null;
    } );
    [/code]

    I haven't actually tested it, as I don't have a table with checkboxes to hand in it, but what it is doing is getting the row indexes for the table and looping over each (in the `map()` ) and adding the data from column index 1 if column index 2 has a checked input in it. Then the `filter()` is finally used to remove the null values.

    Allan
  • rpanditrpandit Posts: 14Questions: 0Answers: 0
    Thanks Allan, will give it a try..
This discussion has been closed.