get cell value from selected row

get cell value from selected row

vansinvansin Posts: 15Questions: 4Answers: 0

Looking for a simple example of how to get a cell value from a selected row.

The code below gets me all of the data in the row. How could I modify this to return only the value in column 4 in the selected row?

        table
            .on('select', function (e, dt, type, indexes) {
                var data = table.row(0).data();
                events.prepend(JSON.stringify(data));
            })

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    As you say, data contains all the data in the row. So you just need to pull out the cell's value that you want.

    Colin

  • vansinvansin Posts: 15Questions: 4Answers: 0

    I am a CPA by profession and not a developer so if you could elaborate on that idea that would help me out! How can I best accomplish this? Thank you!

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    Assuming your data is an array of data use data[3] (zero based indexing).

    Allan

This discussion has been closed.