Capture value cells

Capture value cells

vacanitovacanito Posts: 9Questions: 2Answers: 0
edited July 2018 in Free community support

hello, I need to capture the value of each cell to use a conditional, when using this code I only capture the cells of the first row, which I must modify so that functions in each row. Thanks for the help.

$('#example').on( 'click', 'tbody td:not(:first-child)', function (e) {
  
    var idx = table.cell('selected').index();
    var data = table.rows( idx ).data();
    var vale_1 = data[0]['vale']['data'];
    var vale_2 = data[0]['vale']['data_exit'];

    console.log(vale_1+" "+vale_2)

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    Change:

    table.cell('selected').index();

    To be:

    table.cell(this).index();
    

    Also use idx.row to get the row index from the cell index.

    Allan

  • vacanitovacanito Posts: 9Questions: 2Answers: 0

    Thanks Allan, as always you have the precise answer. ;)

  • vacanitovacanito Posts: 9Questions: 2Answers: 0

    Everything works perfect. What I try to do is to avoid that when one cell is selected another can be selected, the problem is that the alert is activated after the second one is selected, there is an event that activates the alert before on at the same time it is selected

This discussion has been closed.