How to get the value of only the first column of the selected rows?

How to get the value of only the first column of the selected rows?

khmelev77khmelev77 Posts: 6Questions: 3Answers: 0

Hello.
How to get the value of only the first column of the selected rows?

At the moment I get the selected rows the following code:
var selectedData = table.rows('.selected').data();

Answers

  • kthorngrenkthorngren Posts: 21,231Questions: 26Answers: 4,929

    This thread explains how to do this:
    https://datatables.net/forums/discussion/44657

    Kevin

  • khmelev77khmelev77 Posts: 6Questions: 3Answers: 0

    How can I adapt it to my code? I get some errors when trying

  • khmelev77khmelev77 Posts: 6Questions: 3Answers: 0
    function () {
                var selectedData = table.rows('.selected').data();
                alert(selectedData);
                var selectedData2d = array2dToJson(selectedData, 'selectedData');
                var selectedDataStr = JSON.stringify(selectedData2d);
                $.ajax({
                    url: 'test3.php',
                    type: 'post',
                    data: {selectedData: selectedDataStr},
                    success: function(response){
                       result = $.parseJSON(response);
                       $('#result_form').html(result.data);
                    }
                });
    
            }
    
  • kthorngrenkthorngren Posts: 21,231Questions: 26Answers: 4,929

    How can I adapt it to my code?

    var rows = table.rows({selected:true}).indexes();
    var selectedData = table.cells(rows, 2).data();
    

    Where 2 is the column number you want.

    I get some errors when trying

    What are the errors?

    Kevin

This discussion has been closed.