best way to store extra data ?

best way to store extra data ?

dimicdimic Posts: 2Questions: 0Answers: 0
edited August 2011 in General
hi,

I'd like to store additional invisible data at each row. That data is an index of element in the source array.

probably I could use just an index from DataTable (they could be the same, but not sure they are always remains the same actually (due to sort etc)).

I tried to add an invisible column, and then access it's value. But seems like I can't get the data if column is invisible.
[code]
// at initianlization
"aoColumnDefs": [ { "bVisible": false, "aTargets": [ 4 ] } ],
..
// at 'click' processing
$('#cox tr').click( function() {
var rr = $('td', this);
var dc = $(rr[0]).text();
var idd = $(rr[4]).text();
alert(dc+' / '+idd); // idd - is epmty if column is invisible :|
} );
[/code]

could you please advice a solution? thank yo very much

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    you can't get the hidden column data using JQuery, which is just reading the DOM elements, but you CAN get it from the DataTables object.

    [code]
    $('#cox tr').click( function() {
    // get DT's internal row index for this row (where oTable represents your table).
    oTable = $('#cox').dataTable();
    iRow = oTable.fnGetPosition(this);

    // get data at column 4 from DT's internal data, using iRow
    idd = oTable.fnGetData(iRow)[4];
    }
    [/code]
  • dimicdimic Posts: 2Questions: 0Answers: 0
    fbas,

    I appreciate much your help. Thank you very much!

    and all the best to you!

    -
    dm
This discussion has been closed.