Retrieve row data from a clicked row

Retrieve row data from a clicked row

Jason CJason C Posts: 8Questions: 3Answers: 1

Hello all!

I am new to the forums and to DataTables and so far this control looks AMAZING! I am doing a test for my manager today and have several items working correctly. I create my var of the Datatable, throw on a few buttons, etc. get JSON data from the server and populate the table. The one part I cannot seem to get working is simply retrieving the row data from a DataTable grid?

I am going to use the row data to then send back to my server for processing. I have looked at several examples and it is simply beyond me. Does anyone have a very, VERY simple example of capturing the row data on a clicked row via JQuery?

Thank you all!!!
Jason

This question has an accepted answers - jump to answer

Answers

  • Jason CJason C Posts: 8Questions: 3Answers: 1
    edited January 2018 Answer ✓

    SOLVED! I am a goof, I was calling the 'rows' improperly. It kept coming up with a value of [object Object].

    //Incorrect
    var data = table.rows(0).data();
    alert('Value of row is: ' + data[0]);
    

    Instead of this!

    //Correct
    var rows = table.rows(this).data();
    alert('Value of row is:  ' + rows[0].carpar_id);    
    

    Apologies for the trouble,
    Jason

This discussion has been closed.