title: Jquery DataTable get data from row selected on click of button
body: <p>I am trying to have an edit button at the top of a DataTable which will pick up the value from the current selected row and append it to my url.</p>
  
  <p>I have managed to get it working but not quite how I would have liked.</p>
  
  <p>My Edit button which is not using the Datatable properly to get the value stored in the data table.</p>
  
  <pre><code>    $.fn.dataTable.ext.buttons.edit = {
      text: 'Edit',
      action: function () {
          var assetID;
          $("#example tr.selected").each(function (index, row) {
              assetID = ($(row).find("td:nth-child(2)").html());
          });
          if (assetID != null) {
              var url = "/Demo/Edit/" + assetID;
              window.location.href = url;
          }
      }
  };
  </code></pre>
  
  <p>Example from Datatable site of a table with a button which shouts out the data in the current selected row.
  I would so much like to get my data tidier and into the datatable its self.</p>
  
  <pre><code>$(document).ready(function() {
  var events = $('#events');
  var table = $('#example').DataTable( {
      dom: 'Bfrtip',
      select: true,
      buttons: [
          "edit", //my edit button which works but requires external script
          { // Example button from website.
              text: 'Get selected data',
              action: function () {
                  var count = table.rows( { selected: true } ).count();
                //var count = table.rows( { selected: true } ).data();
                // how do i then drill down into count to get value from column 2.
                  events.prepend( '&lt;div&gt;'+count+' row(s) selected&lt;/div&gt;' );
              }
          }
      ]
   } );
   } );
  </code></pre>
  
  <p>I have tried so many ways to try and access the object within the example from the datatables website but I just can not get the value a specific column in the selected row using their methods.</p>
  
  <p>Any help would be much appreciated.</p>