0

I have Try to extract raw data from selected row in jquery datatable. I am using 1.10.7 version.here is my simple code

 var table = $('#Searchtbl').DataTable({
                "columns": [
                            { "data": "poNumber" },
                            { "data": "relnumber" },
                            { "data": "recNumber" },
                            { "data": "vendorName"},

                ],
            });



            $('#Searchtbl tbody').on('dblclick', 'tr', function () {
                console.log(table.row(this).data());
                //$('#searchModel').modal('hide');
            });

but once console get print it saying undefined.Can any one say what i am doing wrong here,

3 Answers 3

4

Finally i fixed this with this way.Reson is the new version of Datatable library no longer working table.row( this ).data() this way

    var table = $('#Searchtbl').DataTable({
    });


    $('#Searchtbl tbody').on('dblclick', 'tr', function () {
        var tableData = $(this).children("td").map(function () {
            return $(this).text();
        }).get();

        alert("Your data is: " + $.trim(tableData[0]) + " , " + $.trim(tableData[1]) + " , " + $.trim(tableData[2])+ " , " + $.trim(tableData[3])+ " , " + $.trim(tableData[4]));

    });

Cheers..

Sign up to request clarification or add additional context in comments.

Comments

0

You need this one ??

 $('#example tbody').on( 'click', 'tr', function () {
     console.log( table.row( this ).data() );
 } );

Detail

1 Comment

yes.the table data Dynamically generate by Ajax Request
0

Get the data onclick

var table = $('#example').DataTable();

$('#example tbody').on( 'click', 'tr', function () {
    console.log( table.row( this ).data() );
} );

All the Details

1 Comment

I want on extract row data when double click on it.i have found answer for it.Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.