Get hidden row value

Get hidden row value

zebra100zebra100 Posts: 4Questions: 2Answers: 0

Hi, please show me how i can alert() a value in the table row from clicking a row link. eg

-------------- initialisation code, data loaded through ajax -------------
"columns": [
{ data: 0 },
{ data: 1 },
{ data: 2 },
{ data: 3 },
{ data: 4 },
{ data: 5 },
{
data: null,
className: "center",
defaultContent: '<a href="" class="editor_edit">Edit</a> / <a href="" class="editor_remove">Delete</a>'
}
]


QUESTION - how do i alert the data [2] value?

$('#data-grid').on('click', 'a.editor_remove', function (e) {
    e.preventDefault();
    alert("delete pressed");   //works

   what is the  code to alert the data[2] value? (i need to pass to modal form)

} );

Thanks in advance for your help.

Paul

Answers

  • user3770935user3770935 Posts: 10Questions: 4Answers: 0

    Check out the example on this page:

    https://datatables.net/reference/api/cell().data()

    It shows how to retrieve the value of a cell clicked on

  • zebra100zebra100 Posts: 4Questions: 2Answers: 0

    Thanks, But how do you get the value from a different cell in the row?

  • user3770935user3770935 Posts: 10Questions: 4Answers: 0
    edited August 2016

    use the index of the column, or name and append it to the data():

            $('#myTable').on( 'click', 'tr', function () {
                alert( table.row().data()[1] );
            } );
    

    This will get whatever is in the second column of the row clicked to alert (array starts at 0).

This discussion has been closed.